Repository navigation
Conversation
Currently there is no logic to handle horizontal scrolling when text is selected. The current code only takes the cursor position into account. This only affects buffers where the softwrap option is disabled. Relocate() computes the StartCol values that keep the cursor's rune visible and the values that make the whole selection visible, and uses their intersection. If the two cannot be combined, because the selection is wider than the window or the cursor is outside the selection, the cursor wins: Relocate() must always keep the cursor in view. The view is then moved as little as possible. See micro-editor#3826
Tests for the horizontal part of BufWindow.Relocate() with softwrap off, which previously had no test coverage. They cover the cursor alone, selections that fit in the window, selections that extend past the window away from the cursor, selections wider than the window, reversed and multi-line selections, tabs, double-width runes, a one column window and an empty line. The predicates shared by all cases state the contract of Relocate(): the cursor stays visible, a selection that fits the window becomes fully visible, and a view that already shows the relevant content is not scrolled.
masmu
force-pushed
the
bug/horizontal-relocate-doesnt-respect-selections
branch
from
November 6, 2026 11:58
d3d120a to
3f3fde1
Compare
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.
Currently there is no logic to handle horizontal scrolling when text is selected. The current code only takes the cursor position into account. This only affects buffers where the
softwrapoption is disabled.How to reproduce:
Bind
onTriggerBugto see the effect.Actual behavior:
You cannot see the selected subword
Widthevery time you triggeronTriggerBug.Expectation:
The selected text should be visible at all times.