Notepad3 icon indicating copy to clipboard operation
Notepad3 copied to clipboard

Behavior of "Change History Margin" with "Revert from File (F5)"

Open hpwamr opened this issue 3 years ago β€’ 1 comments

  • Load a file and make some changes (saved and/or unsaved).

2022-09-03_092656

  • Now reload the file: "Revert from File (F5)"

2022-09-03_092714

Question: Is this the desired behavior of the "Change history margin" after a "Revert from file (F5)" πŸ€”

hpwamr avatar Sep 03 '22 07:09 hpwamr

Just my humble opinion: no, this is not the desired behavior…

Reverting should set everything back – after using the Revert from file (F5) option, I'm sitting in front of the unaltered file in its original state. So I think the change markers should be completely reset as well, the file is not modified in any way.

engelhro avatar Sep 22 '22 07:09 engelhro

My humble opinion is: The change history display is correct: Reverting (from file (F5)) changes the current session by overriding current document by file content, so showing a change marker for complete document is correct. Proof: pressing Ctrl-Z return to previous state (even if there has been no changes). Reverting from file (F5): Current Notepad3 session does not keep a history of file changes by external tools during the session, so it keeps track of current session changes only. Change history marker is correct here.

RaiKoHoff avatar Sep 23 '22 08:09 RaiKoHoff

Easy use-case:

  1. Switch OFF "File Change Notification"
  2. Load any file into NP3.
  3. Change this file on disk, using another editor.
  4. Press Revert from file (F5)

=> Change History Marker tells me: Pressing Ctrl+Z will bring back my previous document, which is different from file content meanwhile.

RaiKoHoff avatar Sep 28 '22 22:09 RaiKoHoff

See first post: Question: Is this the desired behavior of the "Change history margin" after a "Revert from file (F5)" πŸ€”

My humble opinion is: The change history display is correct: Reverting (from file (F5)) changes the current session by overriding current document by file content, so showing a change marker for complete document is correct. Proof: pressing Ctrl-Z return to previous state (even if there has been no changes). Reverting from file (F5): Current Notepad3 session does not keep a history of file changes by external tools during the session, so it keeps track of current session changes only. Change history marker is correct here.

Hello @RaiKoHoff , Since v5.22.1020.1 beta, after a "Revert from file (F5)", the "Change history green marker is no longer displayed ! πŸ€”

Question: Is this a bug or a new behavior of the "Change history margin" after a "Revert from file (F5)" 😬 πŸ€”

hpwamr avatar Nov 12 '22 11:11 hpwamr

Corrected, it works as designed. πŸ‘

hpwamr avatar Nov 14 '22 20:11 hpwamr

replacing SCI_REPLACETARGET calls by SCI_REPLACETARGETMINIMAL

Hello @RaiKoHoff ,

I understand that after a Revert to file (F5) the new SCI_REPLACETARGETMINIMAL keeps the Change history bars on changed lines instead of all lines. πŸ‘

But this behavior of Revert to file (F5) with an unsaved file seems me strange ? πŸ€”

2022-12-16_201121

2022-12-16_201208

hpwamr avatar Dec 16 '22 21:12 hpwamr

In Scintilla's documentation for the new feature SCI_REPLACETARGETMINIMAL you will find:

This is similar to SCI_REPLACETARGET but tries to minimize change history when the current target text shares a common prefix or suffix with the replacement.

So the common prefix is the text before the first change and the common suffix is the text after the last change. I think this method does not care for details between prefix and suffix for performance reasons.

RaiKoHoff avatar Dec 19 '22 08:12 RaiKoHoff