Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix undo in replace mode (#10086)
Conrad Irwinfc08ea9b0dbc
diff --git a/crates/vim/src/replace.rs b/crates/vim/src/replace.rsindex 859289903e0..75185435b0a 100644--- a/crates/vim/src/replace.rs+++ b/crates/vim/src/replace.rs@@ -349,4 +349,13 @@ mod test {]);cx.assert_state("ˇabˇcabcabc", Mode::Replace);}++ #[gpui::test]+ async fn test_replace_undo(cx: &mut gpui::TestAppContext) {+ let mut cx = VimTestContext::new(cx, true).await;++ cx.set_state("ˇaaaa", Mode::Normal);+ cx.simulate_keystrokes(["0", "shift-r", "b", "b", "b", "escape", "u"]);+ cx.assert_state("ˇaaaa", Mode::Normal);+ }}diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rsindex f8782b9444e..ac26f025012 100644--- a/crates/vim/src/vim.rs+++ b/crates/vim/src/vim.rs@@ -390,7 +390,7 @@ impl Vim {{visual_block_motion(true, editor, cx, |_, point, goal| Some((point, goal)))}- if last_mode == Mode::Insert {+ if last_mode == Mode::Insert || last_mode == Mode::Replace {if let Some(prior_tx) = prior_tx {editor.group_until_transaction(prior_tx, cx)}@@ -502,7 +502,9 @@ impl Vim {fn transaction_begun(&mut self, transaction_id: TransactionId, _: &mut WindowContext) {self.update_state(|state| {- let mode = if (state.mode == Mode::Insert || state.mode == Mode::Normal)+ let mode = if (state.mode == Mode::Insert+ || state.mode == Mode::Replace+ || state.mode == Mode::Normal)&& state.current_tx.is_none(){state.current_tx = Some(transaction_id);