NPP_HexEdit icon indicating copy to clipboard operation
NPP_HexEdit copied to clipboard

View in HEX mode permanently remove file's editing history

Open ArkadiuszMichalski opened this issue 5 years ago • 5 comments

When we turn on View in HEX mode and off this mode then we lost all file's editing history (Undo/Redo not work). Is this intentional behavior?

ArkadiuszMichalski avatar Mar 04 '20 14:03 ArkadiuszMichalski

Confirmed. Seems to be a side effect, at least SCI_EMPTYUNDOBUFFER is not called. The Undo/Redo state is available on switching on hex view, but get lost on switching it off.

Also a modified file in normal mode can't be saved any more after switching hex view on and off. Seems somewhere the file status is modified wrong.

chcg avatar Apr 13 '20 17:04 chcg

caused by thie line:

https://github.com/chcg/NPP_HexEdit/blob/e36f71fc9d30ec238a1989ae7b486e4282a83a2d/HexEditor/src/HEXDialog.cpp#L937

KnIfER avatar Sep 08 '20 01:09 KnIfER

Thanks for the hint, see https://github.com/notepad-plus-plus/notepad-plus-plus/blob/783798e1ab5f063911f6863155380d8a7599f89a/PowerEditor/src/NppBigSwitch.cpp#L1041 and https://github.com/notepad-plus-plus/notepad-plus-plus/blob/783798e1ab5f063911f6863155380d8a7599f89a/PowerEditor/src/NppBigSwitch.cpp#L1077

NPPM_ENCODESCI, NPPM_DECODESCI are clearing the undo buffer implicitly.

chcg avatar Sep 08 '20 06:09 chcg

The undo history is inconsistent for hex/normal mode. It must be cleared unless the codepage for normal npp is always ASCII. The only thing I can do is delay the clearing time : Instead of clearing the undo history immediately on toggling hex mode, I managed to do so only when the buffer is edited in the other mode. But that requires the modification of npp itself.

KnIfER avatar Sep 11 '20 04:09 KnIfER

Might be related, but I noticed when in Hex mode, Ctrl+Z/Alt+Backspace to undo don't work, but Edit >> Undo works. I saw some people complaining on StackOverflow that the Hex editor plugin removes history

Darthagnon avatar Jan 09 '23 14:01 Darthagnon