fix(InputHandler): isWrapped correctness after erase and column ops#5995
Draft
Tyriar wants to merge 3 commits into
Draft
fix(InputHandler): isWrapped correctness after erase and column ops#5995Tyriar wants to merge 3 commits into
Tyriar wants to merge 3 commits into
Conversation
eraseInDisplay Ps=1 clears from the start of the viewport through the cursor. When the cursor is in the last column, the following line's isWrapped flag must be cleared because the erased line can no longer continue a wrapped row. _eraseInBufferLine already addresses buffer lines with ybase + y, but the next-line lookup used lines.get(j + 1) without ybase. With scrollback (ybase > 0), that touched the wrong line and left incorrect wrap state on the line below the cursor. Co-authored-by: Cursor <cursoragent@cursor.com>
CSI EL Ps=1 erases from the start of the row through the cursor. When the cursor is in the last column, that clears the entire row but did not clear isWrapped on the following line. eraseInDisplay Ps=1 already handled this case with ybase-aware indexing. Mirror that behavior in eraseInLine so soft-wrap chains stay consistent after erase-to-left at end of line. Co-authored-by: Cursor <cursoragent@cursor.com>
scrollLeft, scrollRight, insertColumns, and deleteColumns set isWrapped=false on every line inside the scroll margins but left the first line below scrollBottom unchanged. A soft wrap spanning the bottom margin and the next row could leave a stale isWrapped flag on the line below, breaking wrapped string translation. Clear isWrapped on the buffer line below the bottom margin after each of these column operations. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Keeps soft-wrap chain integrity after erase sequences and scroll-margin column operations.
Changes
ybase + j + 1instead oflines.get(j + 1)so scrollback does not point at the wrong buffer line.isWrappedon the following line (with unit test).scrollLeft/scrollRight,insertColumns, anddeleteColumns, call new_clearWrapBelowScrollMargins()to clear stale wrap on the first line below the bottom scroll margin.Repro ideas
Risk
Touches CSI erase and margin column behavior. Spec ambiguity: whether clearing wrap below the margin is always required vs. only when the margin line was part of a wrap chain—current approach matches xterm-style conservative clearing (same spirit as existing in-margin
isWrapped = false).Commits (cherry-picked from
tyriar/explore-correctness)0383787— ED Ps=1: ybase when clearing wrap on line below cursor at EOLb679cdc— EL Ps=1: same wrap clear at last column (+ unit test)32ef836— scroll L/R, insert/delete columns: clear wrap below scroll bottom margin