Skip to content

Fix textarea undo crash - #6687

Open
guillaumelgf wants to merge 1 commit into
Textualize:mainfrom
guillaumelgf:fix-textarea-undo-stale-cursor
Open

Fix textarea undo crash#6687
guillaumelgf wants to merge 1 commit into
Textualize:mainfrom
guillaumelgf:fix-textarea-undo-stale-cursor

Conversation

@guillaumelgf

@guillaumelgf guillaumelgf commented Aug 6, 2026

Copy link
Copy Markdown

This PR fixes #6686

Summary

Fixes a TextArea undo crash that can happen after undoing a large multiline paste.

During undo, the document may already be restored to its shorter previous state while the cursor location still temporarily points into the pasted text. If scrollbar refresh tries to scroll that stale cursor location into view, WrappedDocument.location_to_offset() can
raise because the row no longer exists.

This change clamps the cursor location used for the visual offset calculation, without mutating the actual selection. The undo flow can then finish restoring the selection normally.

@guillaumelgf
guillaumelgf marked this pull request as ready for review August 6, 2026 15:42
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.

TextArea undo can crash when a multiline paste is undone after scrollbar state changes

1 participant