Skip to content

Conversation

@dinocosta
Copy link
Member

Fixes an issue where editor::AddSelectionAbove and
editor::AddSelectionBelow, when set with skip_soft_wrap: true ,
would lose track of the original cursor column when passing through
short lines, as editor::Editor.add_selection was not using the oldest
selection's column range when adding a new selection.

These changes update the editor::Editor.add_selection method so as to
keep track of the olde selection's column range for each group, as well
as extracting find_next_columnar_selection_by_display_row and
find_next_columnar_selection_by_buffer_row helper methods to clarify
the two navigation strategies.

Closes #46842

Release Notes:

  • Fixed editor::AddSelectionAbove and editor::AddSelectionBelow when skipping over soft-wrapped lines to preserve the original cursor column when adding selections through lines shorter than the starting position
When using `add_selection_below`/`add_selection_above` with
`skip_soft_wrap: true`, cursors would drift to shorter columns when
passing through short lines. This happened because the code used the
current selection's buffer column instead of preserving the oldest
selection's goal column.

The `add_selection` method has been updated so that we now keep track of
of the column range for the oldest selectio nin each group before
extending, ensuring all new selections aim for the original column
range.
Extract `find_next_columnar_selection_by_display_row` and
`find_next_columnar_selection_by_buffer_row` from the `add_selection`
method to make the two code paths, `skip_soft_wrap: true` and
`skip_soft_wrap: false`, clearer and more self-contained.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 15, 2026
@dinocosta dinocosta self-assigned this Jan 15, 2026
@dinocosta dinocosta merged commit edae88c into main Jan 15, 2026
25 checks passed
@dinocosta dinocosta deleted the 46842-fix-editor-add-selection branch January 15, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

2 participants