notepad-plus-plus icon indicating copy to clipboard operation
notepad-plus-plus copied to clipboard

[FEAT] On file reload : do **NOT** flush undo/redo

Open Kochise opened this issue 1 year ago • 14 comments

Description of the Issue

File opened in editor gets modified by external program. The file is updated in the editor (automatically or manually). The previous version is lost forever, the undo/redo arrows are disabled.

Steps to Reproduce the Issue

  1. See Description just above

Expected Behavior

If file is reloaded due to an external change :

  1. Store current version in undo history
  2. Disable redo
  3. Reload file
  4. If new version is not wanted, click undo to restore previous version
  5. If new version modified, keep it in undo, continue as normal
  6. That's to say we still have "previous" version in undo history

Actual Behavior

  1. See Description just above

Debug Information

No debug to provide.

Kochise avatar Jan 06 '23 14:01 Kochise

This was tried before and was so unsuccessful that it was reverted. I doubt the developers are going to try it again.

alankilborn avatar Jan 06 '23 14:01 alankilborn

In what was it unsuccessful ?

Kochise avatar Jan 06 '23 16:01 Kochise

Search old issues/change logs.

alankilborn avatar Jan 06 '23 17:01 alankilborn

@Kochise,

In what was it unsuccessful ?

Cf. https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5626#issuecomment-499858088:

the biggest problem was, that every reload re-populated the undo buffer, regardless if the file itself was modified or not, causing to run out of memory if either done frequently, or reloading huge files.

see here: #5595

and here: https://notepad-plus-plus.org/community/topic/17530/performance-hit-due-to-allow-undo-on-reload/3

rdipardo avatar Jan 07 '23 08:01 rdipardo

Ok, could it be possible to enable it in Preferences.../MISC/File Status Auto-Detection ?

My use case : was editing a self-modifying file, it emptied itself, lost everything as unable to undo.

Should have enabled backup on save, though.

Kochise avatar Jan 08 '23 08:01 Kochise

Ok, could it be possible to enable it in Preferences.../MISC/File Status Auto-Detection ?

As I said, I don't think developers are going to revisit anything on this.

was editing a self-modifying file, it emptied itself, lost everything

Meaning you got a prompt to reload and said yes to that prompt?

alankilborn avatar Jan 08 '23 10:01 alankilborn

Nope, no prompt, auto-reloaded itself, cleaned the undo buffer.

Kochise avatar Jan 08 '23 10:01 Kochise

What's your setting here:

image

alankilborn avatar Jan 08 '23 10:01 alankilborn

Also, for developers to consider your issue, provide Debug Information.

alankilborn avatar Jan 08 '23 10:01 alankilborn

What's your setting here:

That's how it is... NOW. Before the two boxes were checked.

Kochise avatar Jan 08 '23 11:01 Kochise

Nobody cares how it is NOW; they care how it was when you encountered the conditions of your issue.

Update silently is a bad choice if there is the possibility that you are doing editing of the file and there is the possibility it could be changed by some external process. Perhaps this is obvious now.

alankilborn avatar Jan 08 '23 11:01 alankilborn

Perhaps. The settings are so "hard" to find that I didn't paid attention to it, until it was too late.

Kochise avatar Jan 08 '23 17:01 Kochise

The settings are so "hard" to find that I didn't paid attention to it, until it was too late.

Probably best to leave this one at the "default" value (as I showed in the screenshot), unless one really knows what they're doing. I know this is after-the-fact of loss for you; sorry to hear that.

alankilborn avatar Jan 08 '23 17:01 alankilborn

No problem, life is like that. No one was hurt.

Kochise avatar Jan 08 '23 19:01 Kochise