Skip to content

editor.rereplace() should not replace if data isn't going to be changed #272

Open
@alankilborn

Description

@alankilborn

Consider this script:

def add_1(m):
    z = int(m.group(1))
    return 'Y' + str(z + 1) if z < 100 else m.group(0)

# replace X followed by numbers by an incremented number
# e.g.   X999
# e.g.   X56 X39
# e.g.   X999
# e.g.   X56 X39
# e.g.   X999
# e.g.   X56 X39
#          becomes
#        Y57 Y40 Y1000

editor.rereplace('X([0-9]+)', add_1);

Running this script upon its own source file tab results in:

image

Note that lines 7, 9, 11 have the change-history modified marker, even though the text on this lines is the same as it was before the script was run and the replacements made.

Ideally the text that isn't changed wouldn't be replaced and the result after the replacement would look like this:

image

Using PS2.0 and PS3.10.4.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions