Skip to content

Commit

Permalink
vim: Fix >... (#15404)
Browse files Browse the repository at this point in the history
Co-Authored-By: @Alextopher

Release Notes:

- vim: Fixed a hang when repeating an aborted operation
([#15399](#15399)).
  • Loading branch information
ConradIrwin authored Jul 29, 2024
1 parent f58ef9b commit 6db33b8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
12 changes: 12 additions & 0 deletions crates/vim/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,3 +1448,15 @@ async fn test_visual_indent_count(cx: &mut gpui::TestAppContext) {
cx.simulate_keystrokes("shift-v 2 <");
cx.assert_state(" ˇhi", Mode::Normal);
}

#[gpui::test]
async fn test_record_replay_recursion(cx: &mut gpui::TestAppContext) {
let mut cx = NeovimBackedTestContext::new(cx).await;

cx.set_shared_state("ˇhello world").await;
cx.simulate_shared_keystrokes(">").await;
cx.simulate_shared_keystrokes(".").await;
cx.simulate_shared_keystrokes(".").await;
cx.simulate_shared_keystrokes(".").await;
cx.shared_state().await.assert_eq("ˇhello world"); // takes a _long_ time
}
24 changes: 6 additions & 18 deletions crates/vim/src/vim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,13 @@ fn observe_keystrokes(keystroke_event: &KeystrokeEvent, cx: &mut WindowContext)
return;
}

Vim::update(cx, |vim, cx| match vim.active_operator() {
Some(
Operator::FindForward { .. }
| Operator::FindBackward { .. }
| Operator::Replace
| Operator::Digraph { .. }
| Operator::AddSurrounds { .. }
| Operator::ChangeSurrounds { .. }
| Operator::DeleteSurrounds
| Operator::Mark
| Operator::Jump { .. }
| Operator::Register
| Operator::RecordRegister
| Operator::ReplayRegister,
) => {}
Some(_) => {
vim.clear_operator(cx);
Vim::update(cx, |vim, cx| {
if let Some(operator) = vim.active_operator() {
if !operator.is_waiting(vim.state().mode) {
vim.clear_operator(cx);
vim.stop_recording_immediately(Box::new(ClearOperators))
}
}
_ => {}
});
}

Expand Down
6 changes: 6 additions & 0 deletions crates/vim/test_data/test_record_replay_recursion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"Put":{"state":"ˇhello world"}}
{"Key":">"}
{"Key":"."}
{"Key":"."}
{"Key":"."}
{"Get":{"state":"ˇhello world","mode":"Normal"}}

0 comments on commit 6db33b8

Please sign in to comment.