[TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

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

Moderators: white, Hacker, petermad, Stefan2

User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

[TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *white »

  1. Create 2 text files with the following contents:

    Code: Select all

    1
    2
    3 a b c d e f g h j i k l m n o p q r s t u v w x y z
    4
    5
    

    Code: Select all

    1
    2
    3 a b c d e f g - j i k l m n o p q r s - u v w x y z
    4
    5
    
  2. Make sure you have the default CompareF2Mode=1 (continue in the next line after the last match) in wincmd.ini
  3. Open Compare By Content and compare the 2 files
  4. Press F6 (Edit mode)
  5. Press F2 repeatedly (search next difference within line)
    If you press F2 when the cursor is on the last difference (letter t), a beep sound is played and the cursor is put at the beginning of the line.
    (would be nicer if the cursor did not jump to beginning of the line)
  6. Place the cursor somewhere on line 4 and press F2
    Again, a beep sound is played and the cursor is put at the beginning of the line
  7. Place the cursor somewhere on line 5 and press F2
    A beep sound is played and the cursor is put at the beginning of line 4 :!:
  8. Press Shift+F2 repeatedly
    When no previous difference is found, a beep sound is played and the cursor is put at the beginning of line 3.
  9. Now delete line 1 in both files, press Ctrl+S (Save) and save both files
  10. Move the cursor in the first file again and press Ctrl+End to bring it to the end of the file
  11. Press Alt+C (Compare)
  12. Press Shift+F2 repeatedly
    Unlike what happened in step 8, a beep sound is never played and the cursor stops at the end of line 1 :!:
  13. Now delete line 1 in both files again, press Ctrl+S (Save) and save both files
  14. Move the cursor in the first file again and press Ctrl+End to bring it to the end of the file
  15. Press Alt+C (Compare)
  16. Press Shift+F2 repeatedly
  17. a beep sound is never played and the cursor stops at the letter h :!:
JOUBE
Power Member
Power Member
Posts: 1477
Joined: 2004-07-08, 08:58 UTC

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *JOUBE »

2ghisler(author)
please don't change anything. It's working very well so far. And I can already name 3 problems in 11.01 that arose as side effects because something was changed for formal reasons but that didn't bother anyone before.

I'm afraid something like that would happen here too and it would be very, very annoying and completely unnecessary. This has been around since 2022 and everything has worked well so far! I use it all the time without problems. When has the OP used it before and when will he use it again?

Joube
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *ghisler(Author) »

I also don't think that I should sink a lot of hours into this, it only happens when there are no more results.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *white »

HISTORY.TXT wrote: 09.10.23 Fixed: Compare by content, edit text, find next/previous difference within a line with F2/Shift+F2: Don't move caret when there aren't any more matches (32/64)
Tested OK using TC 11.02rc2 32-bit and 64-bit.

I did notice something with the beep sound. When I press and hold down F2 (or Shift+F2) until no more matches are found, I don't hear a beep sound. But when I release F2 then a beep sound is played much later. The program is responsive in the mean time. So you can move the cursor and edit text for example, and suddenly the beep sound is played.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *ghisler(Author) »

Tested OK using TC 11.02rc2 32-bit and 64-bit.
I cannot guarantee that it will work in all cases, but it should in most (took a few hours to fix).

Regarding the beep sound, I think that this is normal: TC calls MessageBeep, which starts the player in the background to play the beep sound, but returns immediately. When you keep F2 pressed, MessageBeep is called in a tight loop, so the player starts over again and again without ever finishing the beep. Maybe adding a sleep() command after the beep could help, but this would make TC unresponsive for the sleep time...
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *white »

ghisler(Author) wrote: 2023-10-12, 09:27 UTC I cannot guarantee that it will work in all cases, but it should in most (took a few hours to fix).
Thanks, it works much nicer now.
ghisler(Author) wrote: 2023-10-12, 09:27 UTC Regarding the beep sound, I think that this is normal: TC calls MessageBeep, which starts the player in the background to play the beep sound, but returns immediately. When you keep F2 pressed, MessageBeep is called in a tight loop, so the player starts over again and again without ever finishing the beep. Maybe adding a sleep() command after the beep could help, but this would make TC unresponsive for the sleep time...
Or don't try to play another beep sound when a beep sound was played in a shorter time than a certain period ago.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *ghisler(Author) »

OK, I will add that to the next RC. Unfortunately there doesn't seem to be a way to determine the length of MessageBeep, so it's difficult to use an arbitrary length. 1 second may be already too long, when the beep is very short, but I will use that for now.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *white »

HISTORY.XT wrote: 13.10.23 Fixed: Compare by content, find next/previous difference: Don't repeat beep for 1 second when nothing is found, otherwise no beep may be played at all (32/64)
Works for me in TC 11.02rc3. The duration of 1 second is a bit long, but I think it should be a bit long because there might be delays when the sound is played. So I think it's fine.

I don't know if it works satisfactorily on very slow systems. Perhaps someone else can test the beep sound on a slow system.



I did find a bug that slipped through when I tested the previous version. Here is the report:
  • Create 2 files with the following contents:
    (file 1)

    Code: Select all

    0
    2
    3 a b c d e f g h j i k l m o p q r s t u v w x y z
    4
    6
    
    (file 2)

    Code: Select all

    0
    1
    2
    3 a b c d e f g - j i k l m n o p q r s - u v w x y z
    4
    5
    6
    
  • Compare by content the 2 files, file 1 on the left side
  • Press F6 to enter Edit mode
  • Press Ctrl+Home to move the cursor to the beginning of he file
  • Press F2 repeatedly
    The first difference is skipped.
  • Press Ctrl+End to move the cursor to the end of he file
  • Press Shift+F2 repeatedly
    The first difference from the end is skipped.
  • Press Ctrl+Home to move the cursor to the beginning of he file
  • Change "0" into "1"
  • Press Cltr+S and save the left file
  • Press Alt+C to Compare the files
  • Press F2
    The cursor should be on the "h"
  • Press Shift+F2
    The first difference at the beginning of the file is not found.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *ghisler(Author) »

They are skipped because they are empty and too close to the cursor. If you start both files with two lines of zeroes, the first empty result isn't skipped.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *white »

ghisler(Author) wrote: 2023-10-19, 08:56 UTC They are skipped because they are empty and too close to the cursor. If you start both files with two lines of zeroes, the first empty result isn't skipped.
How can a difference be too close? F2 and Shift+F2 is meant to navigate through all differences, even within a line. If you put the cursor on the space after "m" and press F2, TC still finds the empty difference 1 position further ahead.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *ghisler(Author) »

I just described what is happening. There are probably 1000s of such small glitches, it's impossible to fix them all.
Author of Total Commander
https://www.ghisler.com
User avatar
AntonyD
Power Member
Power Member
Posts: 1249
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *AntonyD »

I just described what is happening.
I think that many, after reading this answer, will understand that they are now even more perplexed than they were before....
Do you want to say that there is literally logic in your code that says that if a difference is found and it is too close to the cursor (by the way - what does this mean physically? when a single difference is found, the cursor is not yet exist there... about what kind of proximity can we talk then?) - then do nothing - move on to searching for the next difference????
#146217 personal license
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *ghisler(Author) »

I never said that this was intentional. Missing lines are recorded as having 0 differences, so when the cursor jumps from the first to the second line and looks for differences, it doesn't find any. Then the "Next difference" search is invoked (like the button) and finds the first line with actual differences. To fix this, I have to check whether there is a line on the other side, and if there is, I have to record it as "1 difference, starting at offset 0".
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *white »

HISTORY.TXT wrote: 22.10.23 Fixed: Compare by content, find next/previous difference: Didn't find missing lines on one side where there is a line on the other when the cursor was directly before that line (32/64)
Tested OK using TC 11.02rc4.

But the beep fix doesn't work when using Shift+F2 repeatedly in the last mentioned test scenario.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.01] Compare by Content: F2 and Shift+F2 peculiarities

Post by *ghisler(Author) »

No, I'm doing a normal beep there. But doesn't it jump to the next position then, so it doesn't matter?
Author of Total Commander
https://www.ghisler.com
Post Reply