vim: Refactor and fix multiline operations (#25055)

Changes:
- [x] Cursor at the start during yank operations on objects (`yip`,
`yab` etc).
- [x] Refactors this: Trim all leading and trailing whitespace from
inner multiline bracket selection.
  - This leaves a nicely indented line when doing `ci{` `vi{d` etc
  - [x] Checks for empty selection
  - [x] Removed moving cursor to the start in visual bracket operations

This cleans up the previous implementation by providing a simpler check
in `surrounding_markers`, instead of calling a new function in
`expand_object`. No functionality was changed there except for handling
the empty selection and removing some cursor adjustments that should not
have been there after further testing.

Release Notes:

- N/A
This commit is contained in:
5brian 2025-02-24 20:30:21 -05:00 committed by GitHub
parent 980e1b533f
commit 52f73e0c2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 56 additions and 109 deletions

View file

@ -16,7 +16,7 @@ use workspace::searchable::Direction;
use crate::{
motion::{first_non_whitespace, next_line_end, start_of_line, Motion},
object::{self, Object},
object::Object,
state::{Mode, Operator},
Vim,
};
@ -375,9 +375,6 @@ impl Vim {
} else {
selection.end = range.end;
}
if !around && object.is_multiline() {
object::preserve_indented_newline(map, selection);
}
}
// In the visual selection result of a paragraph object, the cursor is