+[8.51RC1] Resync hides last edited lines

Bug reports will be moved here when the described bug has been fixed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

+[8.51RC1] Resync hides last edited lines

Post by *MVV »

1. Compare two following files:

Code: Select all

I
will

eat.

Code: Select all

I
will
not
eat.
2. Switch to Edit mode, copy line with "not" to first file.
3. Save file.
4. Resync from line with "not" (or any previous line). Line "not" disappears from first file's side in comparer!
5. Continue editing first file. E.g. replace dot with exclamation mark in last line.
6. Save file. Line "not" is removed from first file!

Even when you edit, save and then recompare file(s), resync may hide some lines, so they will be lost after next saving!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I will check it.
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I can confirm the problem: It is caused by the saving function: Since you didn't change anything after saving, TC assume that the files were unchanged, and used the normal compare function instead of recompare with changes. But the changes are based on the original file, not the saved one (so you can undo to a point BEFORE you saved). Therefore these changes have to be taken into account too. I will change it.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Thanks, it doesn't cut strings in RC2.

However I've noticed strange inconsistency: when I close compare tool after step 4, it asks for saving file, but save button is disabled because file was already saved.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, currently it asks a bit too often to save, but better this way than too few saves. I prefer to keep it this way for the moment.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

No, you don't understand. It asks for saving a file even if it wasn't modified after previous saving (when save button is disabled) -- only when I use resync after saving. It seems that resync sets modified flag w/o actual modification.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, this happens when the file has been modified AND the undo history is cleared. In this case, the tool cannot reliably check whether saving is necessary or not, so it asks even if it isn't.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Since resync doesn't change files, I think you should keep modified flag after resync:
1. if file (left or right) was modified before resync, it is still modified after resync;
2. if file wasn't modified before resync (it was just saved or unchanged at all), it is still not modified after resync (until user makes any change of course).
And save button should be active when there are modified files, even if change history is empty. Same thing should be applied to close confirmation.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

It's not that easy: There is no "modified" flag. Instead, TC uses the "undo" queueto determine whether a file was modified or not. When you save a file, TC remembers the position in the undo queue - when you later make more changes, or take back changes until before you saved, this position in the queue changes.

When you recompare, the undo queue is cleared, so TC cannot use this mechanism any more.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

So, you have an undo queue Q and saved queue state index savedPos, right? And file is modified when Q.pos <> savedPos? You can set savedPos to 0 when cleaning queue if file was saved at resync time (assuming Q.pos is 0 in case of empty queue) or set savedPos to e.g. -1 if file was modified (assuming -1 is impossible value for Q.pos so it will never match). Such approach works even w/o modified flag, you only need to compare Q.pos and savedPos in order to determine that file should be saved (and do both enable save button and show warning on close).

It looks really buggy strange when save button is disabled but Comparer asks to save changes on close...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

It's not that easy, but I think that I found a way now - I need to keep track of two different cases:
1. Was the file modified since the file was opened? This defines the recompare method.
2. Was the file modified after it was saved when re-comparing? If yes, it needs to be saved even when there was no change after recomparing.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

It seems that TC 8.51rc3 does it well, there is no more strange confirmation. Thank you!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Actually there was still a problem in RC2 where lines disappeared, which is fixed now too:
1. Edit one of the files
2. Re-sync from here -> still OK
3. Save files
4. Again re-sync from here -> line disappeared again

This was all due to the combined flag which remembered whether the file was modified. Using two flags as described above seems to solve all these problems.
Author of Total Commander
https://www.ghisler.com
Post Reply