TrimTrailingWhitespace and InsertFinalNewline in SaveFile() mutate buffer lines directly, bypassing the undo system. In VS Code, these save-time cleanups are undoable with Ctrl+Z.
Fix: perform the trim/newline insertion at the app layer using EditCommands before calling SaveFile, so the changes are recorded in the undo stack.
TrimTrailingWhitespace and InsertFinalNewline in SaveFile() mutate buffer lines directly, bypassing the undo system. In VS Code, these save-time cleanups are undoable with Ctrl+Z.
Fix: perform the trim/newline insertion at the app layer using EditCommands before calling SaveFile, so the changes are recorded in the undo stack.