Skip to content

feat: undo and redo many steps in Windows 10 Notepad (0.4.1) - #2

Merged
raf-li merged 2 commits into
mainfrom
feat/multi-undo
Oct 8, 2026
Merged

raf-li merged 2 commits into
mainfrom
feat/multi-undo

Conversation

@raf-li

@raf-li raf-li commented Oct 8, 2026

Copy link
Copy Markdown
Member

Windows 10's Notepad keeps a single undo step, and its second control+Z redoes it. This adds many-step undo and redo, like VS Code:

  • control+Z goes back one step at a time, control+Y or control+shift+Z forward again.
  • A step is a run of typing (it ends at a one-second pause or a move to another line) or one Code Compass command (line moves, comments, rename, reload...). Auto-close and indentation while typing join the typing.
  • The changed line is read. Going back to the saved text clears the "*" in the title.
  • A history belongs to one document in one Notepad window: File > Open or New starts a new one, so undo never brings back another file's text; Save As keeps it. Notepad++, Windows 11 Notepad and single-line fields keep their own control+Z.
  • On by default; a setting turns it off.

Implementation: undo.py (no NVDA imports) keeps only the changed part between stops; the plugin records stops on typing pauses, line moves, saves and around its own commands, and applies steps with edit_control.replace.

Checked by a two-agent review with adversarial verification; its 8 findings are fixed in the second commit, with tests. 499 tests pass. Merging publishes 0.4.1 (buildVars.py and CHANGELOG.md updated).

🤖 Generated with Claude Code

raf-li and others added 2 commits October 8, 2026 12:31
Notepad's edit control keeps one undo step, and a second control+Z
redoes it. Code Compass now records the document at undo stops (a pause
in typing, a caret move to another line, a save, and before and after
each of its own commands), keeping only what changed, and control+Z,
control+Y and control+shift+Z walk through those steps. Typing edits
such as auto-close and indentation join the typing around them. A new
document in the window (another title, or a changed text that Notepad
reports as unmodified) starts a new history, so undo never brings back
another file's text. Undoing back to the saved text clears the "*".
On by default; a setting turns it off. Version 0.4.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes for the many-step undo:
- A document replaced through File > Open or File > New (Notepad calls
  it unchanged) starts a new history when the editor gets focus and
  before undo or redo, so control+Z never brings back the previous
  file's text. A save under a new name keeps the history only for that
  very text, and the save's note is dropped once the save is handled.
- Histories belong to Notepad's own top-level window and title, not to
  the window in front (Find, Save As, another program) or to the edit
  control, which Word Wrap replaces.
- The history starts when the editor gets focus, so the first typing in
  a document can be undone.
- The common start and end of two texts are found block by block, so a
  step in a large file costs little.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raf-li
raf-li merged commit 58e4e21 into main Oct 8, 2026
3 checks passed
@raf-li
raf-li deleted the feat/multi-undo branch October 8, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant