vim: Change line up and change line down respect indentation (#28934)
When using 'c' with line-wise motions like j/k, operate like cc to fix indentation issues. Closes #28933 Release Notes: - `c j` and `c k` now respect indentation
This commit is contained in:
parent
f6d13645ce
commit
5f7189e5af
3 changed files with 30 additions and 1 deletions
|
@ -62,7 +62,10 @@ impl Vim {
|
||||||
&text_layout_details,
|
&text_layout_details,
|
||||||
forced_motion,
|
forced_motion,
|
||||||
);
|
);
|
||||||
if let Motion::CurrentLine = motion {
|
if matches!(
|
||||||
|
motion,
|
||||||
|
Motion::CurrentLine | Motion::Down { .. } | Motion::Up { .. }
|
||||||
|
) {
|
||||||
let mut start_offset =
|
let mut start_offset =
|
||||||
selection.start.to_offset(map, Bias::Left);
|
selection.start.to_offset(map, Bias::Left);
|
||||||
let classifier = map
|
let classifier = map
|
||||||
|
@ -422,6 +425,15 @@ mod test {
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.assert_matches();
|
.assert_matches();
|
||||||
|
cx.simulate(
|
||||||
|
"c k",
|
||||||
|
indoc! {"
|
||||||
|
The quick
|
||||||
|
brown fox
|
||||||
|
ˇjumps over"},
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.assert_matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
@ -463,6 +475,15 @@ mod test {
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.assert_matches();
|
.assert_matches();
|
||||||
|
cx.simulate(
|
||||||
|
"c j",
|
||||||
|
indoc! {"
|
||||||
|
The quick
|
||||||
|
ˇbrown fox
|
||||||
|
jumps over"},
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.assert_matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
|
|
@ -14,3 +14,7 @@
|
||||||
{"Key":"c"}
|
{"Key":"c"}
|
||||||
{"Key":"j"}
|
{"Key":"j"}
|
||||||
{"Get":{"state":"The quick\nbrown fox\nˇ","mode":"Normal"}}
|
{"Get":{"state":"The quick\nbrown fox\nˇ","mode":"Normal"}}
|
||||||
|
{"Put":{"state":"The quick\n ˇbrown fox\n jumps over"}}
|
||||||
|
{"Key":"c"}
|
||||||
|
{"Key":"j"}
|
||||||
|
{"Get":{"state":"The quick\n ˇ","mode":"Insert"}}
|
||||||
|
|
|
@ -14,3 +14,7 @@
|
||||||
{"Key":"c"}
|
{"Key":"c"}
|
||||||
{"Key":"k"}
|
{"Key":"k"}
|
||||||
{"Get":{"state":"ˇ\nbrown fox\njumps over","mode":"Normal"}}
|
{"Get":{"state":"ˇ\nbrown fox\njumps over","mode":"Normal"}}
|
||||||
|
{"Put":{"state":"The quick\n brown fox\n ˇjumps over"}}
|
||||||
|
{"Key":"c"}
|
||||||
|
{"Key":"k"}
|
||||||
|
{"Get":{"state":"The quick\n ˇ","mode":"Insert"}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue