Fix panic in increment

This commit is contained in:
Conrad Irwin 2023-10-04 15:13:01 -06:00
parent 7d94b0325f
commit a4e77af571
2 changed files with 13 additions and 4 deletions

View File

@ -78,10 +78,14 @@ fn increment(vim: &mut Vim, mut delta: i32, step: i32, cx: &mut WindowContext) {
2 => format!("{:b}", result),
_ => unreachable!(),
};
if selection.is_empty() {
new_anchors.push((false, snapshot.anchor_after(range.end)))
}
edits.push((range, replace));
edits.push((range.clone(), replace));
}
if selection.is_empty() {
new_anchors.push((false, snapshot.anchor_after(range.end)))
}
} else {
if selection.is_empty() {
new_anchors.push((true, snapshot.anchor_after(start)))
}
}
}
@ -226,6 +230,8 @@ mod test {
cx.assert_matches_neovim("(ˇ0b10f)", ["ctrl-a"], "(0b1ˇ1f)")
.await;
cx.assert_matches_neovim("ˇ-1", ["ctrl-a"], "ˇ0").await;
cx.assert_matches_neovim("banˇana", ["ctrl-a"], "banˇana")
.await;
}
#[gpui::test]

View File

@ -13,3 +13,6 @@
{"Put":{"state":"ˇ-1"}}
{"Key":"ctrl-a"}
{"Get":{"state":"ˇ0","mode":"Normal"}}
{"Put":{"state":"banˇana"}}
{"Key":"ctrl-a"}
{"Get":{"state":"banˇana","mode":"Normal"}}