Skip to content

fix: keep oversized deletions within valid undo positions - #126

Open
PerchAnton wants to merge 1 commit into
rhysd:mainfrom
PerchAnton:codex/empty-delete-preserves-history
Open

PerchAnton wants to merge 1 commit into
rhysd:mainfrom
PerchAnton:codex/empty-delete-preserves-history

Conversation

@PerchAnton

@PerchAnton PerchAnton commented Oct 25, 2026 •

Copy link
Copy Markdown

Deleting past the end of a buffer could record a one-past-the-last row in undo history. Ctrl+U then restores that invalid cursor and panics. An empty delete also created a history entry and discarded redo.

Resolve an oversized deletion's endpoint to the actual final character before recording history. Return false for an empty range, preserving redo. Add four regression tests and extend the existing deletion matrix to check cursor validity after undo and the documented no-op return value.

Related: #121. The problem also reproduces without select_all, including a Unicode multiline buffer. This fixes the recorded endpoint rather than clamping an invalid cursor after undo.

Validation on Rust 1.99.1/macOS arm64:

  • Two new regressions failed before the fix; the oversized deletion panicked through TextArea::input.
  • cargo test --features search: 160 passed, 23 ignored (including doctests).
  • Both CONTRIBUTING Clippy feature combinations pass, additionally with -D warnings; cargo fmt --check passes.
  • Three external interaction traces fail on upstream and pass against this fix (14 steps), also in the external adapter CI. The external runner is an experimental tool I maintain; it is not added as an upstream dependency.

The delete-chunk history path also uses next_back instead of last to keep current stable Clippy clean; it retrieves the same final drained line. GitHub reports no native workflow runs/checks for this PR or its fork yet; the passing external adapter job does not substitute for the full native CI matrix.

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