editor: Fix add selection when skipping over soft-wrapped lines#46911
Merged
editor: Fix add selection when skipping over soft-wrapped lines#46911
Conversation
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.
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.
Fixes an issue where
editor::AddSelectionAboveandeditor::AddSelectionBelow, when set withskip_soft_wrap: true,would lose track of the original cursor column when passing through
short lines, as
editor::Editor.add_selectionwas not using the oldestselection's column range when adding a new selection.
These changes update the
editor::Editor.add_selectionmethod so as tokeep track of the olde selection's column range for each group, as well
as extracting
find_next_columnar_selection_by_display_rowandfind_next_columnar_selection_by_buffer_rowhelper methods to clarifythe two navigation strategies.
Closes #46842
Release Notes:
editor::AddSelectionAboveandeditor::AddSelectionBelowwhen skipping over soft-wrapped lines to preserve the original cursor column when adding selections through lines shorter than the starting position