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
|
@ -3269,18 +3269,6 @@ async fn test_backspace(cx: &mut TestAppContext) {
|
|||
ˇtwo
|
||||
ˇ threeˇ four
|
||||
"});
|
||||
|
||||
// Test backspace with line_mode set to true
|
||||
cx.update_editor(|e, _, _| e.selections.line_mode = true);
|
||||
cx.set_state(indoc! {"
|
||||
The ˇquick ˇbrown
|
||||
fox jumps over
|
||||
the lazy dog
|
||||
ˇThe qu«ick bˇ»rown"});
|
||||
cx.update_editor(|e, window, cx| e.backspace(&Backspace, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
ˇfox jumps over
|
||||
the lazy dogˇ"});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -3300,16 +3288,6 @@ async fn test_delete(cx: &mut TestAppContext) {
|
|||
fouˇ five six
|
||||
seven ˇten
|
||||
"});
|
||||
|
||||
// Test backspace with line_mode set to true
|
||||
cx.update_editor(|e, _, _| e.selections.line_mode = true);
|
||||
cx.set_state(indoc! {"
|
||||
The ˇquick ˇbrown
|
||||
fox «ˇjum»ps over
|
||||
the lazy dog
|
||||
ˇThe qu«ick bˇ»rown"});
|
||||
cx.update_editor(|e, window, cx| e.backspace(&Backspace, window, cx));
|
||||
cx.assert_editor_state("ˇthe lazy dogˇ");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -4928,7 +4906,7 @@ async fn test_copy_trim(cx: &mut TestAppContext) {
|
|||
r#" «for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);ˇ»
|
||||
end = cmp::min(max_point, Point::new(end.row + 1, 0));
|
||||
|
@ -4943,7 +4921,7 @@ async fn test_copy_trim(cx: &mut TestAppContext) {
|
|||
"for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);"
|
||||
.to_string()
|
||||
|
@ -4958,7 +4936,7 @@ async fn test_copy_trim(cx: &mut TestAppContext) {
|
|||
"for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);"
|
||||
.to_string()
|
||||
|
@ -4970,7 +4948,7 @@ if is_entire_line {
|
|||
r#" « for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);ˇ»
|
||||
end = cmp::min(max_point, Point::new(end.row + 1, 0));
|
||||
|
@ -4985,7 +4963,7 @@ if is_entire_line {
|
|||
" for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);"
|
||||
.to_string()
|
||||
|
@ -5000,7 +4978,7 @@ if is_entire_line {
|
|||
"for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);"
|
||||
.to_string()
|
||||
|
@ -5012,7 +4990,7 @@ if is_entire_line {
|
|||
r#" «ˇ for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);»
|
||||
end = cmp::min(max_point, Point::new(end.row + 1, 0));
|
||||
|
@ -5027,7 +5005,7 @@ if is_entire_line {
|
|||
" for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);"
|
||||
.to_string()
|
||||
|
@ -5042,7 +5020,7 @@ if is_entire_line {
|
|||
"for selection in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);"
|
||||
.to_string()
|
||||
|
@ -5054,7 +5032,7 @@ if is_entire_line {
|
|||
r#" for selection «in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);ˇ»
|
||||
end = cmp::min(max_point, Point::new(end.row + 1, 0));
|
||||
|
@ -5069,7 +5047,7 @@ if is_entire_line {
|
|||
"in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);"
|
||||
.to_string()
|
||||
|
@ -5084,7 +5062,7 @@ if is_entire_line {
|
|||
"in selections.iter() {
|
||||
let mut start = selection.start;
|
||||
let mut end = selection.end;
|
||||
let is_entire_line = selection.is_empty() || self.selections.line_mode;
|
||||
let is_entire_line = selection.is_empty();
|
||||
if is_entire_line {
|
||||
start = Point::new(start.row, 0);"
|
||||
.to_string()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue