WinMerge / winmerge

WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
https://winmerge.org/
GNU General Public License v2.0
6.07k stars 775 forks source link

Replace text issue #2279

Closed rxa1031 closed 2 months ago

rxa1031 commented 3 months ago

Hi All,

When replacing text using Replace (CTRL+H), it is observed that the second replace button press results in incorrect data/text replacement.

https://github.com/WinMerge/winmerge/assets/18160755/f7bcdda1-b8e9-4a5e-9de2-c2f5fa30dc6f

Sample test/example below:

Original: image

Changed: image

Please help fix the issue.

Regards, Rajeev

sdottaka commented 3 months ago

I tried to reproduce this issue as shown in the GIF animation below, but was unable to do so. Which version of WinMerge are you using? If it is not the latest version, please try the latest version. #2279

rxa1031 commented 3 months ago

image

I highlight the text that needs to be replaced, then press CTRL + H, then change replace in to whole file. Finally I click at least one line above or on the extreme left of the line that has the first occurrence of the text that needs change. Then I press the shown button sequence.

rxa1031 commented 3 months ago

I confirm the issue is only observed when a part of the text to be searched is highlighted and then CTRL + H is pressed. As the search (and replace) movement is from top to bottom. I need to place the cursor either on the left side of the first word/text/sub-sting/string to be replaced or on any line that is above the first word/text/sub-sting/string to be replaced. I then click the Find Next button. Once the first replace text gets highlighted I start clicking the replace button, until I am done with all replaces.

sdottaka commented 2 months ago

Although different from your video, I was able to reproduce the strange behavior shown in the video below. I'll take a look at it later.

#2279_2

rxa1031 commented 2 months ago

Since I wanted to replace ndom, I am only highlighting ndom and then pressing CTRL + H

rxa1031 commented 2 months ago

The size of the captured video would have been greater than 10 MBs and hence could only a part of the whole process. My office laptop does not have an IT approved tool for video compression.

sdottaka commented 2 months ago

Finally, I am now able to reproduce this issue as well. To reproduce this problem, it was necessary to enable Automatic rescan in the Editor category of the Options window.

image

rxa1031 commented 2 months ago

Current used settings in my case (Automatic rescan is disabled): image

rxa1031 commented 2 months ago

Used general settings: image

rxa1031 commented 2 months ago

https://github.com/WinMerge/winmerge/assets/18160755/37007adf-6d78-43e2-9427-f0d764c81fe2

sdottaka commented 2 months ago

I need to place the cursor either on the left side of the first word/text/sub-sting/string to be replaced or on any line that is above the first word/text/sub-sting/string to be replaced

Thank you for attaching the video. I missed the above. I was able to reproduce this issue as well.

I fixed this issue in commit d3ab50c.

You can download the latest CI artifacts from the URL below.

https://ci.appveyor.com/project/sdottaka/winmerge/build/artifacts https://github.com/WinMerge/winmerge/actions/runs/8670205946

Thank you for your report.