Open tumatanquang opened 1 year ago
Unfortunately, "Replace with" doesn't allow you to specify a regular expression. If you change the settings of the PrediffLineFilter plugin as follows, will it work?
Unfortunately, "Replace with" doesn't allow you to specify a regular expression. If you change the settings of the PrediffLineFilter plugin as follows, will it work?
No, it doesn't work either!
To reproduce the problem, we need to at least know all the characters to the left and right of the line. Could you put all the characters on the left and right of that one line here?
To reproduce the problem, we need to at least know all the characters to the left and right of the line. Could you put all the characters on the left and right of that one line here?
Left line: Macro.bytMaxHintWidth = (byte)((Macro.SCREEN_WIDTH >> Macro.BW_16) - 2);
Right line: Macro.bytMaxHintWidth = (byte)(Macro.SCREEN_WIDTH / 16 - 2);
I also tried to disable Use RegExp
but it did not work.
I think the below regex will do the trick.
Find what: (([^(]+) >> Macro.BW_(\d+))
Find what: \(([^(]+) >> Macro\.BW_(\d+)\)
Replace with: $1 / $2
I think the below regex will do the trick.
Find what: (([^(]+) >> Macro.BW_(\d+)) Replace with: $1 / $2
It does not work: I tried escaped dot but it was the same, did not work:
I'm sorry. It appears that the backslashes disappeared due to the rules of markdown. How about changing it to the following?
Find what: \(([^(]+) >> Macro\.BW_(\d+)\)
Replace with: $1 / $2
I'm sorry. It appears that the backslashes disappeared due to the rules of markdown. How about changing it to the following?
Find what:
\(([^(]+) >> Macro\.BW_(\d+)\)
Replace with: $1 / $2
Yes, it worked in specific cases:
Left line: Macro.bytMaxHintWidth = (byte)((Macro.SCREEN_WIDTH >> Macro.BW_16) - 2);
Right line: Macro.bytMaxHintWidth = (byte)(Macro.SCREEN_WIDTH / 16 - 2);
Find what
will have to be ignored with two values of Replace with
. For example:
Macro.BW_16
will only identical with 2 values are:/ 16
or>> 4
And will NOT be identical to other values with the above two values. The above regex rules can only match the first value (/ 16
).
Left line:
new byte[]{(byte)(_x + Param.getInstance().CAMERAX >> Macro.BW_16), (byte)(_y + Param.getInstance().CAMERAY >> Macro.BW_16)};
Right line:new byte[]{(byte)((_x + Param.getInstance().CAMERAX) / 16), (byte)((_y + Param.getInstance().CAMERAY) / 16)};
P/s: Only differ in>> Macro.BW_16
and/ 16
but also do not ignore it.
Unfortunately, it's hard to get those patterns to work.
If you can tolerate the side effect of ignoring the difference between "(" and ")" then something like the following will work.
Unfortunately, it's hard to get those patterns to work.
If you can tolerate the side effect of ignoring the difference between "(" and ")" then something like the following will work.
Certainly, I don't care about ignoring the difference between "(" and ")", but maybe you are misunderstood my point. Examples of the case of ignoring and not ignoring:
Find what:
>> Macro.BW_16
Replace with:/ 16
=> will ignore Replace with:>> 4
=> will ignore Replace with:/ 4
OR>> 8
(and other value) => will NOT ignore
Examples of identical and non-identical cases that I would like:
Left line:
((Macro.SCREEN_WIDTH >> Macro.BW_16) - 2);
Right line:(Macro.SCREEN_WIDTH / 16 - 2);
=> Will identical. Left line:((Macro.SCREEN_WIDTH >> Macro.BW_16) - 2);
Right line:((Macro.SCREEN_WIDTH >> 4) - 2);
=> Will identical. Left line:((Macro.SCREEN_WIDTH >> Macro.BW_16) - 2);
Right line:(Macro.SCREEN_WIDTH / 8 - 2);
=> Will NOT identical. Left line:((Macro.SCREEN_WIDTH >> Macro.BW_16) - 2);
Right line:((Macro.SCREEN_WIDTH >> 8) - 2);
=> Will NOT identical.
Your 4th – 7th regex rule is misinterpreting what I meant. And all those rules won't work in cases where the front of that line contains something:
Left line:
return new byte[]{(byte)(_x + Param.getInstance().CAMERAX >> Macro.BW_16), (byte)(_y + Param.getInstance().CAMERAY >> Macro.BW_16)};
Right line:byte[] _xy = new byte[]{(byte)((_x + Param.getInstance().CAMERAX) / 16), (byte)((_y + Param.getInstance().CAMERAY) / 16)};
Perhaps I am misunderstanding, but I think it is to be expected that the following differences are not ignored.
Left line: ((Macro.SCREEN_WIDTH >> Macro.BW_16) - 2); Right line: (Macro.SCREEN_WIDTH / 8 - 2); => Will NOT identical.
If the Right line is (Macro.SCREEN_WIDTH / 16 - 2);
I can see that the difference would be ignored, but since it is 8 and not 16, the result seems correct.
Left line: ((Macro.SCREEN_WIDTH >> Macro.BW_16) - 2); Right line: ((Macro.SCREEN_WIDTH >> 8) - 2); => Will NOT identical.
Similarly, if the Right line were (Macro.SCREEN_WIDTH >> 4 - 2);
I can see that the difference would be ignored, but since it is 8 and not 4, the result seems correct.
Left line: return new byte[]{(byte)(_x + Param.getInstance().CAMERAX >> Macro.BW_16), (byte)(_y + Param.getInstance().CAMERAY >> Macro.BW_16 )}; } Right line: byte[] _xy = new byte[]{(byte)((_x + Param.getInstance().CAMERAX) / 16), (byte)((_y + Param.getInstance().CAMERAY) / 16)};
Unfortunately, if even a portion of the resultant lines substituted by the substitution filter do not match, the differences in those lines are not ignored. This is a limitation of the current substitution filter: if "byte[] _xy = " at the beginning of the Right line is "return" then the difference will be ignored.
Perhaps I am misunderstanding, but I think it is to be expected that the following differences are not ignored.
If the Right line is
(Macro.SCREEN_WIDTH / 16 - 2);
I can see that the difference would be ignored, but since it is 8 and not 16, the result seems correct.Similarly, if the Right line were
(Macro.SCREEN_WIDTH >> 4 - 2);
I can see that the difference would be ignored, but since it is 8 and not 4, the result seems correct.
I mean you misunderstood these syntax:
Find what
is always: >> Macro.BW_X
.
It will be identical to: >> X
or X / 2
.
Suppose: >> Macro.BW_16
will be identical to >> 4
or identical to / 16
(>> Macro.BW_16
identical [>> 4
|| / 16
]).
Unfortunately, if even a portion of the resultant lines substituted by the substitution filter do not match, the differences in those lines are not ignored. This is a limitation of the current substitution filter: if "byte[] _xy = " at the beginning of the Right line is "return" then the difference will be ignored.
I mean: It doesn't matter to me whether byte[] _xy =
and return
are ignored or not. But >> Macro.BW_16
and / 16
was not ignored in this case:
I mean: It doesn't matter to me whether byte[] _xy = and return are ignored or not. But >> Macro.BW_16 and / 16 was not ignored in this case:
I understand that you want to ignore the difference between ">> Macro.BW_16" and "/16", but unfortunately the current Substitution filters only apply per line. If the difference between "byte[] _xy" and "return" is resolved, the difference on that line will be ignored.
I mean: It doesn't matter to me whether byte[] _xy = and return are ignored or not. But >> Macro.BW_16 and / 16 was not ignored in this case:
I understand that you want to ignore the difference between ">> Macro.BW_16" and "/16", but unfortunately the current Substitution filters only apply per line. If the difference between "byte[] _xy" and "return" is resolved, the difference on that line will be ignored.
Yes. However, both the Substitution Filters and PrediffLineFilter.sct plugin are not working correctly. Now I just want it to ignore (not highlight) when encountering the cases that I have specified (>> Macro.BW_X
). It doesn't matter if it ignores other cases that have changes in the same line or not.
@sdottaka I have created a Find what
and Replace with
table to indicate my desired behavior: For each value in the Find what
column, if it has been changed to the corresponding value in the Replace with
column, the tool will igore (not highlight) those changes.
Unfortunately, the 5th to 8th definitions will not work. This is because these definitions are applied sequentially from the top, but "Macro.BW" has already been replaced with "/ " by the 1st to 4th definitions. Therefore, when applying the 5th to 8th definitions, "Macro.BW" no longer exists.
Unfortunately, the 5th to 8th definitions will not work. This is because these definitions are applied sequentially from the top, but "Macro.BW" has already been replaced with "/ " by the 1st to 4th definitions. Therefore, when applying the 5th to 8th definitions, "Macro.BW" no longer exists.
It seems that this is a highlight error that has occurred. As far as I understand, the PrediffLineFilter.sct plugin will replace the Find what
value with the corresponding value in Replace with
. In the example case you provided:
Left line: Macro.bytMaxHintWidth = (byte)((Macro.SCREEN_WIDTH >> Macro.BW_16) - 2);
Right line: Macro.bytMaxHintWidth = (byte)(Macro.SCREEN_WIDTH / 16 - 2);
The left line will be replaced with: Macro.bytMaxHintWidth = (byte)((Macro.SCREEN_WIDTH / 16) - 2);
If so, the tool should only highlight left line as follows: Macro.bytMaxHintWidth = (byte)((
Macro.SCREEN_WIDTH >> Macro.BW_16)
- 2);
But in reality, it has ignored all the changes from the PrediffLineFilter.sct plugin and highlighted the changes as if there were no changes from the PrediffLineFilter.sct plugin.
Isn't it because there is a definition that ignores "(" and ")" like the following? Also, I think my wording is bad, so I'll say it again, Substitution filters such as PrediffLineFilter.sct are only applied line by line. Even if two lines are almost identical after being substituted by the Substitution filters, all inline differences will be highlighted if there are any remaining differences within the line.
Isn't it because there is a definition that ignores "(" and ")" like the following? Also, I think my wording is bad, so I'll say it again, Substitution filters such as PrediffLineFilter.sct are only applied line by line. Even if two lines are almost identical after being substituted by the Substitution filters, all inline differences will be highlighted if there are any remaining differences within the line.
I apologize, because I explain it is confusing.
I used Beyond Compare software. That software has the Replacements
feature, I have set the rules I want. I want WinMerge to do the same thing:
P/s: The right-hand side of line 3 has been edited by me using photo editing software to change the value to / 16
.
I understand that you want it to behave like the image above, but with the current WinMerge Substitution filters feature, you can't get results like the one above. I understand this issuse is an enhancement request.
I am using version 2.16.30 (x64-PerUser). I want to ignore parts of the line so I wrote the rules according to two comments #597525 and #303958: These are rules in
PrediffLineFIlter.sct
: P/s: I have correctly edited the desired file extension: These are rules inSubstitution Filters
: However, all of them do not work (red frame part): I tried to disable 1 of 2 then tried again but the results were still similar. Something is not right here? Why does it not ignore the part of the line based on the rules that I have made?