mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Fix vim panic when over-shooting with j
This commit is contained in:
parent
4331cb8058
commit
8de67fd9d9
@ -533,7 +533,7 @@ fn down(
|
|||||||
|
|
||||||
let new_row = cmp::min(
|
let new_row = cmp::min(
|
||||||
start.row() + times as u32,
|
start.row() + times as u32,
|
||||||
map.buffer_snapshot.max_point().row,
|
map.fold_snapshot.max_point().row(),
|
||||||
);
|
);
|
||||||
let new_col = cmp::min(goal_column, map.fold_snapshot.line_len(new_row));
|
let new_col = cmp::min(goal_column, map.fold_snapshot.line_len(new_row));
|
||||||
let point = map.fold_point_to_display_point(
|
let point = map.fold_point_to_display_point(
|
||||||
|
@ -575,6 +575,26 @@ async fn test_folds(cx: &mut gpui::TestAppContext) {
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_folds_panic(cx: &mut gpui::TestAppContext) {
|
||||||
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
|
cx.set_neovim_option("foldmethod=manual").await;
|
||||||
|
|
||||||
|
cx.set_shared_state(indoc! { "
|
||||||
|
fn boop() {
|
||||||
|
ˇbarp()
|
||||||
|
bazp()
|
||||||
|
}
|
||||||
|
"})
|
||||||
|
.await;
|
||||||
|
cx.simulate_shared_keystrokes(["shift-v", "j", "z", "f"])
|
||||||
|
.await;
|
||||||
|
cx.simulate_shared_keystrokes(["escape"]).await;
|
||||||
|
cx.simulate_shared_keystrokes(["g", "g"]).await;
|
||||||
|
cx.simulate_shared_keystrokes(["5", "d", "j"]).await;
|
||||||
|
cx.assert_shared_state(indoc! { "ˇ"}).await;
|
||||||
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_clear_counts(cx: &mut gpui::TestAppContext) {
|
async fn test_clear_counts(cx: &mut gpui::TestAppContext) {
|
||||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
|
12
crates/vim/test_data/test_folds_panic.json
Normal file
12
crates/vim/test_data/test_folds_panic.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{"SetOption":{"value":"foldmethod=manual"}}
|
||||||
|
{"Put":{"state":"fn boop() {\n ˇbarp()\n bazp()\n}\n"}}
|
||||||
|
{"Key":"shift-v"}
|
||||||
|
{"Key":"j"}
|
||||||
|
{"Key":"z"}
|
||||||
|
{"Key":"f"}
|
||||||
|
{"Key":"escape"}
|
||||||
|
{"Key":"g"}
|
||||||
|
{"Key":"g"}
|
||||||
|
{"Key":"5"}
|
||||||
|
{"Key":"d"}
|
||||||
|
{"Key":"j"}
|
Loading…
Reference in New Issue
Block a user