winmerge icon indicating copy to clipboard operation
winmerge copied to clipboard

Is the replacement filter not working?

Open SamuelPlentz opened this issue 3 years ago • 3 comments

In our SQL code we comment code with dashes like this: -- commented code When a code segment is commented out, I want to see if there were no changes beside the comment action.

So I created a replacement filter to replace -- by nothing. This works fine in some cases:

grafik

Unfortunately if I compare this:

ghi

abc

def

klm

to that:

ghx

--abc
--
--def

klx

For me the result is not like expected: grafik

To me it looks like the replacement filter is only used after the initial this line matches that line-algorithm has been executed. I think for my use case it would be great if the replacement filter was executed first, so that the this line matches that line-algorithm can take advantage of the information the replacement filter provides (that difference is not relevant).

Here are my questions: Am I doing it wrong? Is this a bug or only a missing feature? Is there any option I can adjust, or is there an similar feature that could me help out here? (I am aware of manually using search and replace.)

SamuelPlentz avatar Dec 20 '21 09:12 SamuelPlentz

To me it looks like the replacement filter is only used after the initial this line matches that line-algorithm has been executed.

Unfortunately, the Substitution filters are implemented exactly as you thought. I would like to improve this behavior in the future.

Instead, use the PrediffLineFilter plugin, which does exactly what Substitution filters do.

A demo can be found at the following URL

https://github.com/WinMerge/winmerge/discussions/550#discussioncomment-277938

sdottaka avatar Dec 20 '21 11:12 sdottaka

Thanks a lot for the pointer to #550.

I like that substitution filter GUI more. Could you point out where the current implementation (after the this line matches that line-algorithm) is useful? Just want to understand. I see no advantages at all.

I would like to improve this behavior in the future.

Thats a great info.

SamuelPlentz avatar Dec 20 '21 12:12 SamuelPlentz

Could you point out where the current implementation (after the this line matches that line-algorithm) is useful?

It is easy to implement and has the advantage of being fast because the substitution is done only in the diff block. However, it often does not give the expected result, so it is better to change this.

sdottaka avatar Dec 20 '21 12:12 sdottaka