mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Fix panic in increment (#3084)
Release Notes: - Fixes a panic in vim when incrementing a non-number.
This commit is contained in:
commit
427a857e9a
@ -78,10 +78,14 @@ fn increment(vim: &mut Vim, mut delta: i32, step: i32, cx: &mut WindowContext) {
|
|||||||
2 => format!("{:b}", result),
|
2 => format!("{:b}", result),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
if selection.is_empty() {
|
edits.push((range.clone(), replace));
|
||||||
new_anchors.push((false, snapshot.anchor_after(range.end)))
|
}
|
||||||
}
|
if selection.is_empty() {
|
||||||
edits.push((range, replace));
|
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)")
|
cx.assert_matches_neovim("(ˇ0b10f)", ["ctrl-a"], "(0b1ˇ1f)")
|
||||||
.await;
|
.await;
|
||||||
cx.assert_matches_neovim("ˇ-1", ["ctrl-a"], "ˇ0").await;
|
cx.assert_matches_neovim("ˇ-1", ["ctrl-a"], "ˇ0").await;
|
||||||
|
cx.assert_matches_neovim("banˇana", ["ctrl-a"], "banˇana")
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
@ -13,3 +13,6 @@
|
|||||||
{"Put":{"state":"ˇ-1"}}
|
{"Put":{"state":"ˇ-1"}}
|
||||||
{"Key":"ctrl-a"}
|
{"Key":"ctrl-a"}
|
||||||
{"Get":{"state":"ˇ0","mode":"Normal"}}
|
{"Get":{"state":"ˇ0","mode":"Normal"}}
|
||||||
|
{"Put":{"state":"banˇana"}}
|
||||||
|
{"Key":"ctrl-a"}
|
||||||
|
{"Get":{"state":"banˇana","mode":"Normal"}}
|
||||||
|
Loading…
Reference in New Issue
Block a user