editor: Ignore soft wrapped lines when adding selection above or below (#40190)

- Add `skip_soft_wrap` field to both `AddSelectionAbove` and
`AddSelectionBelow` actions. When set to `true`, which is now 
the default this will skip soft wrapped lines when extending the 
selections.
- Move the `start_of_relative_buffer_row` function from the
`vim::motion` module to the `editor::display_map::DisplaySnapshot`
implementation as a method.
- Update the default behavior for both `editor: add selection above` and
`editor: add selection below` commands in order to skip over soft
wrapped lines by default, mirroring VS Code's default behavior.
- Update existing keymaps to specify this `skip_soft_wrap` value for
both `AddSelectionAbove` and `AddSelectionBelow` actions.

Closes #16979 

Release Notes:

- Updated both the `editor: add selection above` and `editor: add
selection below` commands to ignore soft wrapped lines. If you wish to
restore the old behavior, add the following to your keymap file:
  ```
  {
    "context": "Editor",
    "bindings": {
"cmd-alt-up": ["editor::AddSelectionAbove", { "skip_soft_wrap": false
}],
"cmd-alt-down": ["editor::AddSelectionBelow", { "skip_soft_wrap": false
}]
    }
  }
  ```

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
Dino
2025-10-16 11:56:57 +01:00
committed by GitHub
co-authored by Smit Barmase
parent 86ce4ef3ab
commit 5c4f1e6b85
18 changed files with 191 additions and 66 deletions
+4 -5
View File
@@ -15,10 +15,7 @@ use workspace::searchable::Direction;
use crate::{
Vim,
motion::{
Motion, MotionKind, first_non_whitespace, next_line_end, start_of_line,
start_of_relative_buffer_row,
},
motion::{Motion, MotionKind, first_non_whitespace, next_line_end, start_of_line},
object::Object,
state::{Mark, Mode, Operator},
};
@@ -406,7 +403,9 @@ impl Vim {
// Move to the next or previous buffer row, ensuring that
// wrapped lines are handled correctly.
let direction = if tail.row() > head.row() { -1 } else { 1 };
row = start_of_relative_buffer_row(map, DisplayPoint::new(row, 0), direction).row();
row = map
.start_of_relative_buffer_row(DisplayPoint::new(row, 0), direction)
.row();
}
s.select(selections);