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.62k stars 808 forks source link

Poor compare experience with Substitution Filters #2221

Open andry81 opened 9 months ago

andry81 commented 9 months ago

I know the Substitution Filters had issues some time ago: https://github.com/WinMerge/winmerge/issues?q=is%3Aissue+is%3Aopen+substitution+filters

But mine filters is not much complicated and I know it has been working some time ago. But Winmerge keep has having a poor result on comparing files with lines has differenced only in prefix characters even if they are removed by the substitution filters.

Here is the example for reproduction.

Left tab file: https://github.com/andry81/tacklebar/blob/1f90345e8ae66ccc5d2bc25e0a99e8b3bed3f1ce/changelog.txt Right tab file: https://github.com/andry81/tacklebar/blob/1f90345e8ae66ccc5d2bc25e0a99e8b3bed3f1ce/userlog.md

Substitution Filters:

Find what Replace with Regular expression
^* :[^:]+: * [x]
^## (\d\d\d\d.\d\d.\d\d:) \1 [x]

If try to compare with the substitution filters enabled, then there would be a comparison mess and Winmerge will treat 2 text files as completely different when it is not.

The userlog.md actually just a filtered, decorated and user friendly variant of the changelog.txt file (if you interested why these files exists: https://gist.github.com/andry81/d278e6d129ca1af326eafb67470a2ae3).

To force Winmerge to compare them correctly I have to use Notepad++ MultiReplace plugin with these lists: https://github.com/andry81/tacklebar/tree/HEAD/deploy/notepad%2B%2B/plugins/MultiReplace/Lists/winmerge

With the plugin I can strip (undecorate) the userlog.md, merge it from the changelog.txt and then, redecorate it back. But all of these is a workaround to the not working Substitution Filters.

Is there a chance to fix Substitution Filters?

sdottaka commented 9 months ago

Unfortunately, the current Substitutions filter replaces each Diff block after comparison and re-compares each Diff block, so it often does not yield the expected results.

A similar function, PrediffLineFilter plugin, performs replacement before comparison, so it seems to give better results.

If you configure as below and apply this plugin, you will get better results than the Substitutions filter. (Note: Regular expressions and replacement strings have been changed for this plugin. e.g.) ^* :[^:]+:^\* :[^:]+: \1$1

image image image

andry81 commented 9 months ago

@sdottaka

Unfortunately, the current Substitutions filter replaces each Diff block after comparison and re-compares each Diff block, so it often does not yield the expected results.

Why not add the option when to filter: Before compare, After compare?