Skip to content

Clear stale isWrapped when resize skips reflow for cursor line#5810

Closed
dolonet wants to merge 1 commit intoxtermjs:masterfrom
dolonet:fix/3482-stale-iswrapped-reflow
Closed

Clear stale isWrapped when resize skips reflow for cursor line#5810
dolonet wants to merge 1 commit intoxtermjs:masterfrom
dolonet:fix/3482-stale-iswrapped-reflow

Conversation

@dolonet
Copy link
Copy Markdown

@dolonet dolonet commented Apr 13, 2026

Fixes #3482.

What

When resizing to a wider terminal, _reflowLarger skips merging a wrapped-line group if the cursor is inside that group — the comment already notes that "the program will handle fixing up wrapped lines with the cursor". But the wrapped rows keep isWrapped = true even though their content no longer wraps in the new width. Any consumer of isWrapped (triple-click selection is the user-visible symptom in the issue) then treats the now-visually-separate rows as a single logical line.

Fix

Inside the cursor-skip branch, clear isWrapped on any continuation row whose predecessor no longer fills the new last column. The predecessor's last cell has already been null-padded by the pre-reflow line resize, so hasContent(newCols - 1) is a reliable signal that the wrap cannot exist at the new width.

Content on the cursor line is deliberately left alone — only the flag is cleaned up, matching the "program will fix up" contract.

Repro

Before:

cols=5, two rows "aaaaa" / "bbbbb" (isWrapped=true), cursor inside group
→ resize cols=10 → line0="aaaaa     " line1="bbbbb     " isWrapped=true (stale)
→ triple-click selects both rows

After: line1.isWrapped === false; triple-click selects only one row.

Test

Added should clear stale isWrapped when the cursor is on a wrapped line and reflow is skipped (#3482) in Buffer.test.ts.

When resizing to a wider layout and the cursor sits inside a wrapped
line group, reflowLarger intentionally skips merging that group to
avoid disturbing the cursor. The wrapped rows were left with
isWrapped=true even though their content no longer wraps in the new
width, which made triple-click (and any isWrapped-driven logic) treat
the now-visually-separate rows as a single logical line.

Clear isWrapped on any continuation row whose predecessor no longer
fills the new last column. The predecessor's last cell has been
null-padded during the pre-reflow line resize, so hasContent(newCols-1)
is a reliable test.

Fixes #3482
@dolonet dolonet closed this by deleting the head repository Apr 13, 2026
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.

isWrapped isn't updated when resize occurs

1 participant