chcg / NPP_HexEdit

Notepad++ Plugin Hexedit
825 stars 156 forks source link

View in HEX mode permanently remove file's editing history #27

Open ArkadiuszMichalski opened 4 years ago

ArkadiuszMichalski commented 4 years ago

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?

chcg commented 4 years ago

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.

KnIfER commented 4 years ago

caused by thie line:

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

chcg commented 4 years ago

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.

KnIfER commented 4 years ago

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.

Darthagnon commented 1 year ago

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