vim: Handle exclusive-linewise edgecase correctly (#27786)
Before this change we didn't explicitly handle vim's exclusive-linewise edgecase (https://neovim.io/doc/user/motion.html#exclusive). Instead we had hard-coded workarounds in a few places to make our tests pass. The most pernicious of these workarounds was that we represented a visual line selection as including the trailing newline (or leading newline for files that end with no newline), which other code had to undo to get back to what the user indended. Closes #21440 Updates #6900 Release Notes: - vim: Fixed `d]}` to not delete the closing brace - vim: Fixed `d}` from the start of the line to not delete the paragraph separator - vim: Fixed `d}` from the middle of the line to not delete the final newline
This commit is contained in:
parent
e1e8c1786e
commit
fc269dfaf9
27 changed files with 471 additions and 482 deletions
|
@ -55,14 +55,8 @@ impl Vim {
|
|||
}
|
||||
SurroundsType::Motion(motion) => {
|
||||
motion
|
||||
.range(
|
||||
&display_map,
|
||||
selection.clone(),
|
||||
count,
|
||||
true,
|
||||
&text_layout_details,
|
||||
)
|
||||
.map(|mut range| {
|
||||
.range(&display_map, selection.clone(), count, &text_layout_details)
|
||||
.map(|(mut range, _)| {
|
||||
// The Motion::CurrentLine operation will contain the newline of the current line and leading/trailing whitespace
|
||||
if let Motion::CurrentLine = motion {
|
||||
range.start = motion::first_non_whitespace(
|
||||
|
@ -72,11 +66,7 @@ impl Vim {
|
|||
);
|
||||
range.end = movement::saturating_right(
|
||||
&display_map,
|
||||
motion::last_non_whitespace(
|
||||
&display_map,
|
||||
movement::left(&display_map, range.end),
|
||||
1,
|
||||
),
|
||||
motion::last_non_whitespace(&display_map, range.end, 1),
|
||||
);
|
||||
}
|
||||
range
|
||||
|
@ -89,7 +79,7 @@ impl Vim {
|
|||
let start = range.start.to_offset(&display_map, Bias::Right);
|
||||
let end = range.end.to_offset(&display_map, Bias::Left);
|
||||
let (start_cursor_str, end_cursor_str) = if mode == Mode::VisualLine {
|
||||
(format!("{}\n", pair.start), format!("{}\n", pair.end))
|
||||
(format!("{}\n", pair.start), format!("\n{}", pair.end))
|
||||
} else {
|
||||
let maybe_space = if surround { " " } else { "" };
|
||||
(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue