Repository navigation
Conversation
Both methods treated getViewportY() — the distance scrolled back from the live bottom — as an absolute row index. Whenever scrollback existed they anchored selections on scrollback-head rows instead of the visible viewport, so select() silently selected the wrong line and selectAll() produced text disjoint from what the user saw. select() now maps viewport rows through viewportRowToAbsolute(), the same mapping selectLines() uses. selectAll() now spans the whole buffer: [0, scrollbackLength + rows - 1], matching what getSelection() can extract and what "select all" means. Regression tests cover both: selectAll() over scrollback+screen, and select() on viewport row 0 with scrollback present. Fixes coder#233 (selection part)
This branch has not been deployed
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
select()andselectAll()treatedgetViewportY()— the distance scrolled back from the live bottom — as an absolute row index. Whenever scrollback existed, both anchored selections on scrollback-head rows instead of the visible viewport:select(row, col, len):absoluteRow = viewportY + rowlandedviewportYrows too deep in scrollback, silently selecting the wrong line.selectAll(): produced[viewportY, viewportY + rows)— the wrong band of scrollback, disjoint from what the user sees.Fix
select()now maps viewport rows throughviewportRowToAbsolute()— the same mappingselectLines()already uses.selectAll()now spans the whole buffer:[0, getScrollbackLength() + rows - 1].Tests
Two regression tests, run against real WASM scrollback (50 lines written into a 24-row terminal):
selectAll selects scrollback plus screen, not scrollback-head rows— selection text contains scrollback (SB000–SB026) and screen rows.select() anchors on the viewport, not scrollback-head rows—select(0, 0, 5)returns the top visible line (SB027), previouslySB000.Both fail on main, pass with the fix.
prettier,biome,tsc --noEmit, andbun test(361 tests) are clean.Refs #233 — the selection half of that issue (the outside-click
clearSelection()on document clicks is a separate design question, not addressed here).Discovery
Found via terminu's ctx-menu "select all" → copy producing scrollback-head text instead of the screen; verified against
selection-manager.tsinlib/.