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.47k stars 801 forks source link

Allow adding manual compare markers or something similar to assist with the compare process. #1030

Open mdell-seradex opened 2 years ago

mdell-seradex commented 2 years ago

This may be a difficult request, but I hope you like this and can do make it happen. 🙂 Basically, this is my issue.

Sometimes when I am comparing code, the comparison matches on the wrong if, loop, method, etc. I try to adjust the comparison by adding new lines, or even lines with a special character that cannot match any other line to assist in aligning the match, but it does not always work. When this occurs it often results in a large section of the code being mismatched. In many cases this is due to whitespace differences at the start of the line and causes the routine to match a different line with closer whitespace even though the next lines do not match at all. What I would like is a way to mark the points in each file that should match to help the comparison generate more correct results. An alternative, which may work better would be to mark sections of the file to be ignored during the comparison.

Note that I don't want these markings to be saved in the file itself. I would generally be ok with them being temporary and lost once the file is closed, but I could see a case for them to be saved in an alternate file, like a workspace file.

What I am envisioning is some UI in the margin (where the line numbers are displayed), that is perhaps interacted with via a context menu where the user could add, remove, and perhaps adjust these markings. They could show in the margin as a different colour line number, or a different background on the line number. You could even make this controllable in the options like so many other colour settings are.

I hope you like this idea! If you have any questions, or would like a sample, please let me know. I will see what I can do to assist you. 😀

Thank you

sdottaka commented 2 years ago

Perhaps it's close to the functionality of Synchronization points, which WinMerge already has.

The gif animation below demonstrates 'Match similar lines' and 'Synchronization points'.

https://github.com/WinMerge/winmerge/issues/1008#issuecomment-942796328

mdell-seradex commented 2 years ago

I have tried the "Match similar lines" functionality before and found it to not work well for me in many cases. I was not aware of the "Synchronization points" functionality. It appears that it could be essentially what I was looking for. It even has a visual indicator which I did not notice at first. Note that I was thinking of something that would be more directly a part of the primary user interface instead of at the bottom of the Merge menu. I don't consider this Merge functionality, and as such was not looking there. I would have expected it more in the Edit menu. It also does not appear to have a way to clear or adjust a single sync point.

mdell-seradex commented 2 years ago

I just found an issue with the synchronization markers. It seems that they are not always working. As you can see, I created a synchronization marker between lines 1044 and 1061, but it is not linking them up and it is not showing this correctly in the lower pane. It is like WinMerge is saying that because "I think that lines 1044 and 1062 are a better match, then I don't care what you are telling me, Mr. End user". image

sdottaka commented 2 years ago

Unfortunately, this comes from the fact that the Synchronization Point implementation simply divides the file by the marked lines and compares them.

This is equivalent to the fact that the first line on the left is not always in the same position as the first line on the right when compared.

Unfortunately, I don't have an idea to solve this at the moment.

mdell-seradex commented 2 years ago

@sdottaka, I get what you mean now. Other than interrupting the comparison and telling it "No! Match these!", I guess the best way would be for the sync point to cause a break at the start AND end of the selected line.

I see that I can achieve this manually by putting another sync point on the next line of each file, but it would be nice if I didn't have to.

P.S. Please add the ability to manage the sync points, even if it is a way to simply remove the one on the current line. Thank you

OfekShilon commented 10 months ago

Deleting a single sync point is important to me too.

mdell-seradex commented 10 months ago

I have found ways to work around this that typically work. When the sync marker refuses to match up, as I mentioned, I add additional ones to force it, usually on the next line. To delete a single sync point, I usually place my cursor at the start of one of the lines, press enter and then backspace. Unfortunately, that means the file gets marked as modified, but I may be able to handle that by undoing that change. That being said, it would be nice if I didn't have to do these.

There is another concern I have, which is why I sometimes still simply modify the file to get it to re-sync, instead of using the markers, which is that the marked lines obscure the match status of those lines. In other words, I cannot discern if the lines where I set a sync point are an exact match, or if there is some difference, other than by manually reviewing the line.