Compare by contents fails to resync automatically

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

JoopNL
Junior Member
Junior Member
Posts: 7
Joined: 2011-10-15, 15:55 UTC

Compare by contents fails to resync automatically

Post by *JoopNL »

Hi, first of all, thank you Christian for this great tool! I've been using it almost daily for close to 25 years!

I want to report a bug in the Compare by Content feature. When comparing code files, I very often have to manually resync the comparison in very simple situations. An example: Image: https://images2.imgbox.com/f4/1e/xLaoxJOk_o.png

The wrong lines are put together here. Th and th should not be enough reason to match these lines, while the identical line is found just below that. The case sensitive checkbox makes no difference here by the way. At the end of both files are two identical lines, but these are also not matched. So to get to the comparison I want (and in my opinion the correct comparison), I have to resync manually twice. This comparison was with "Ignore repeated spaces" on, which is what I mostly use. Turning this off makes it worse though. Also see that another tool, like the KDiff3 example, does get this right the first time.

Please fix/improve this.

You may say this is "by design". In that case, please move this topic to a feature request. :D In any case I think it would be very beneficial if this could be improved!

The two files in text form:

Code: Select all

File 1:
Please Fix( this )
{
    switch( this )
    {
        // Total Commander rocks
    }   
}

File 2:
Please Fix( this )
{
    if ( fixed ) // Thank you!
    {
        switch( this )
        {
            // Total Commander rocks even more
        }
    }
}
JOUBE
Power Member
Power Member
Posts: 1507
Joined: 2004-07-08, 08:58 UTC

Re: Compare by contents fails to resync automatically

Post by *JOUBE »

Not a real solution (maybe you want to set Comparetool=KDiff3 instead in the ini), but do you have tried this: on both sides mark the line "switch( this )", right mouse click -> context menu -> resync from here (do this in the non edit mode)?

Joube
JoopNL
Junior Member
Junior Member
Posts: 7
Joined: 2011-10-15, 15:55 UTC

Re: Compare by contents fails to resync automatically

Post by *JoopNL »

Uhm, yes. I literally said "I have to resync manually twice". :)

I like the built in tool, it's fast, integrated. I use external tools when I need to, but most of the time the built in tool is enough, if not for this one bug. :(
JOUBE
Power Member
Power Member
Posts: 1507
Joined: 2004-07-08, 08:58 UTC

Re: Compare by contents fails to resync automatically

Post by *JOUBE »

JoopNL wrote: 2023-07-02, 19:23 UTC Uhm, yes. I literally said "I have to resync manually twice".
But twice? With my "solution" only once. That is the reason why I post it.

Joube
JoopNL
Junior Member
Junior Member
Posts: 7
Joined: 2011-10-15, 15:55 UTC

Re: Compare by contents fails to resync automatically

Post by *JoopNL »

Ah, yes, it's needed twice. After the first sync, like you suggest, it still won't sync up the last 2 lines properly.
So first sync is on "switch( this )" and second sync is on the second-last line (line number 6 on the left side in screenshot).
JOUBE
Power Member
Power Member
Posts: 1507
Joined: 2004-07-08, 08:58 UTC

Re: Compare by contents fails to resync automatically

Post by *JOUBE »

JoopNL wrote: 2023-07-02, 20:00 UTC Ah, yes, it's needed twice. After the first sync, like you suggest, it still won't sync up the last 2 lines properly.
So first sync is on "switch( this )" and second sync is on the second-last line (line number 6 on the left side in screenshot).
This is particularly unfortunate if the file has more lines and such differences in between. In such cases I use HI.

Joube
JoopNL
Junior Member
Junior Member
Posts: 7
Joined: 2011-10-15, 15:55 UTC

Re: Compare by contents fails to resync automatically

Post by *JoopNL »

Your suggestion of using the CompareTool= option was a good idea! I've set it to code.exe -d to open the files in compare mode in VS Code, which is also my primary text editor. The integrated compare tool in VS code does handle situations like these correctly. So gonna try that out for while. :) Thanks for the idea!

I still think it would be very nice if the TC compare tool could be fixed/improved in this regard though!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Compare by contents fails to resync automatically

Post by *ghisler(Author) »

I'm sorry but I don't see a solution here. The "switch ( this )" part is indented more in one file than the other, so the two will not appear as identical. Some of the braces are detected as identical, so the line sin between will not be moved. The compare tool in VS code is optimized for the languages it supports, so it knows that for the switch ( this ) part the indentation doesn't matter.
Author of Total Commander
https://www.ghisler.com
JoopNL
Junior Member
Junior Member
Posts: 7
Joined: 2011-10-15, 15:55 UTC

Re: Compare by contents fails to resync automatically

Post by *JoopNL »

Ok, but as you saw KDif3f also recognizes this correctly and doesn't have any knowledge about specific languages.

Would changing the "Ignore repeated spaces" option to "Ignore repeated white space" not be a step in the right direction? Then the additional tab character would be ignored and it would see it as the same line?

I really don't think it's required to know the specific language. The tool should at least recognize that there are two options (lines) to sync to here. And then it should decide based on some rules or "weights" which match is the best, and come to the conclusion that the other line matches way better. The only difference there is a single tab. While the only match on the original line are the letters TH, not even in the same case. The fact that the two lines after this line also match much better could be part of the decision making. Although I realize this takes more computation.

It kind of sounds like that the decision algorithm where to sync to is just too basic right now.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Compare by contents fails to resync automatically

Post by *ghisler(Author) »

Yes, it is very basic, it just looks for the nearest matching two lines (square distance). It doesn't compare unequal lines at all.
However, I'm getting better results by using the same strategy as within a line: The next match has to be at least x lines long. While I'm using 3 characters within a line, it's probably better to limit it to 2 lines which must match.
Author of Total Commander
https://www.ghisler.com
JOUBE
Power Member
Power Member
Posts: 1507
Joined: 2004-07-08, 08:58 UTC

Re: Compare by contents fails to resync automatically

Post by *JOUBE »

ghisler(Author) wrote: 2023-07-04, 10:23 UTCWhile I'm using 3 characters within a line, it's probably better to limit it to 2 lines which must match.
To be honest, in the meantime I had been looking for a configuration option for this in the ini in connection with this thread and was quite surprised that I didn't find anything there, because I thought I remembered that you could set something there *). Unfortunately, this is not the case, so it would be a suggestion (maybe for Tc11?).

Joube

*) But CompareExtraLines=n isn't it.
User avatar
AntonyD
Power Member
Power Member
Posts: 1256
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Compare by contents fails to resync automatically

Post by *AntonyD »

2ghisler(Author)
OK, dear author- what about my example?
https://ibb.co/k4KYC5c
I cant even FORCIBLY to "Resync comparison from ..." line on left panel #47 with line #42 on right panel!
Even if we and code definitely see that there is only ONE! difference!
Yes, as a matter of fact, you can and as well as we all can be sure that the whole difference in all these lines is only in one digit on each line!
On the left the sequence is 13/14/15/16 and on the right it is 12/13/14/15
And I absolutely cannot even force Total to start comparing these strings as 99% identical - with a difference of one character.
Why is Total so resistant? It does not even try to bring these lines into one row!
#146217 personal license
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48232
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Compare by contents fails to resync automatically

Post by *ghisler(Author) »

In this screenshots, ALL lines except for button14= are different. There is nothing equal to be found which would allow the tool to compare the two files.
Author of Total Commander
https://www.ghisler.com
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Compare by contents fails to resync automatically

Post by *Usher »

AntonyD wrote: 2023-07-04, 14:33 UTC what about my example?
https://ibb.co/k4KYC5c
Synchronization fails on every "Iconic1x=0" line, because there are only TWO characters after different "x" in every line. Replace "=0" with "=00" in both files and run Compare by content again - it should work.
Do you know any better solution or workaround?
Andrzej P. Wozniak
Polish subforum moderator
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Compare by contents fails to resync automatically

Post by *Usher »

ghisler(Author) wrote: 2023-07-04, 15:35 UTC There is nothing equal to be found
There is a problem with shifted buttons/items/positions which can be seen as a case of Off by one bug.
Andrzej P. Wozniak
Polish subforum moderator
Post Reply