editor: Fix text manipulation on line mode selections (#37646)

This commit updates the implementation for
`editor::Editor.manipulate_text` to use
`editor::selections_collection::SelectionsCollection.all_adjusted`
instead of `editor::selections_collection::SelectionsCollection.all`, as
the former takes into account the selection's `line_mode`, fixing the
issue where, if an user was in vim's visual line mode, running the
`editor: convert to upper case` command would not work as expected.

Closes #36953 

Release Notes:

- Fixed bug where using the editor's convert case commands while in
vim's Visual Line mode would not work as expected
This commit is contained in:
Dino
2025-09-05 10:12:51 -07:00
committed by GitHub
parent b3405c3bd1
commit b65fb06264
2 changed files with 21 additions and 3 deletions
+7 -3
View File
@@ -11391,14 +11391,17 @@ impl Editor {
let mut edits = Vec::new();
let mut selection_adjustment = 0i32;
for selection in self.selections.all::<usize>(cx) {
for selection in self.selections.all_adjusted(cx) {
let selection_is_empty = selection.is_empty();
let (start, end) = if selection_is_empty {
let (word_range, _) = buffer.surrounding_word(selection.start, false);
(word_range.start, word_range.end)
} else {
(selection.start, selection.end)
(
buffer.point_to_offset(selection.start),
buffer.point_to_offset(selection.end),
)
};
let text = buffer.text_for_range(start..end).collect::<String>();
@@ -11409,7 +11412,8 @@ impl Editor {
start: (start as i32 - selection_adjustment) as usize,
end: ((start + text.len()) as i32 - selection_adjustment) as usize,
goal: SelectionGoal::None,
..selection
id: selection.id,
reversed: selection.reversed,
});
selection_adjustment += old_length - text.len() as i32;