Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor compare experience with Substitution Filters #2221

Open
andry81 opened this issue Feb 20, 2024 · 2 comments
Open

Poor compare experience with Substitution Filters #2221

andry81 opened this issue Feb 20, 2024 · 2 comments

Comments

@andry81
Copy link

andry81 commented Feb 20, 2024

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
Copy link
Member

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
Copy link
Author

andry81 commented Feb 23, 2024

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants