Fix some cases of broken repeat in vim
This commit is contained in:
parent
194e0f3231
commit
4e118f3dd7
4 changed files with 29 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
use crate::Vim;
|
use crate::{insert::NormalBefore, Vim};
|
||||||
use editor::{Editor, EditorEvent};
|
use editor::{Editor, EditorEvent};
|
||||||
use gpui::{AppContext, Entity, EntityId, View, ViewContext, WindowContext};
|
use gpui::{Action, AppContext, Entity, EntityId, View, ViewContext, WindowContext};
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.observe_new_views(|_, cx: &mut ViewContext<Editor>| {
|
cx.observe_new_views(|_, cx: &mut ViewContext<Editor>| {
|
||||||
|
@ -34,8 +34,7 @@ fn focused(editor: View<Editor>, cx: &mut WindowContext) {
|
||||||
|
|
||||||
fn blurred(editor: View<Editor>, cx: &mut WindowContext) {
|
fn blurred(editor: View<Editor>, cx: &mut WindowContext) {
|
||||||
Vim::update(cx, |vim, cx| {
|
Vim::update(cx, |vim, cx| {
|
||||||
vim.workspace_state.recording = false;
|
vim.stop_recording_immediately(NormalBefore.boxed_clone());
|
||||||
vim.workspace_state.recorded_actions.clear();
|
|
||||||
if let Some(previous_editor) = vim.active_editor.clone() {
|
if let Some(previous_editor) = vim.active_editor.clone() {
|
||||||
if previous_editor
|
if previous_editor
|
||||||
.upgrade()
|
.upgrade()
|
||||||
|
|
|
@ -493,4 +493,17 @@ mod test {
|
||||||
cx.simulate_keystrokes(["escape"]);
|
cx.simulate_keystrokes(["escape"]);
|
||||||
cx.assert_state("ˇjhello\n", Mode::Normal);
|
cx.assert_state("ˇjhello\n", Mode::Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_repeat_over_blur(cx: &mut gpui::TestAppContext) {
|
||||||
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
|
|
||||||
|
cx.set_shared_state("ˇhello hello hello\n").await;
|
||||||
|
cx.simulate_shared_keystrokes(["c", "f", "o", "x", "escape"])
|
||||||
|
.await;
|
||||||
|
cx.assert_shared_state("ˇx hello hello\n").await;
|
||||||
|
cx.simulate_shared_keystrokes([":", "escape"]).await;
|
||||||
|
cx.simulate_shared_keystrokes(["."]).await;
|
||||||
|
cx.assert_shared_state("ˇx hello\n").await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,8 @@ pub struct NeovimBackedTestContext {
|
||||||
|
|
||||||
impl NeovimBackedTestContext {
|
impl NeovimBackedTestContext {
|
||||||
pub async fn new(cx: &mut gpui::TestAppContext) -> NeovimBackedTestContext {
|
pub async fn new(cx: &mut gpui::TestAppContext) -> NeovimBackedTestContext {
|
||||||
|
#[cfg(feature = "neovim")]
|
||||||
|
cx.executor().allow_parking();
|
||||||
// rust stores the name of the test on the current thread.
|
// rust stores the name of the test on the current thread.
|
||||||
// We use this to automatically name a file that will store
|
// We use this to automatically name a file that will store
|
||||||
// the neovim connection's requests/responses so that we can
|
// the neovim connection's requests/responses so that we can
|
||||||
|
|
11
crates/vim/test_data/test_repeat_over_blur.json
Normal file
11
crates/vim/test_data/test_repeat_over_blur.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{"Put":{"state":"ˇhello hello hello\n"}}
|
||||||
|
{"Key":"c"}
|
||||||
|
{"Key":"f"}
|
||||||
|
{"Key":"o"}
|
||||||
|
{"Key":"x"}
|
||||||
|
{"Key":"escape"}
|
||||||
|
{"Get":{"state":"ˇx hello hello\n","mode":"Normal"}}
|
||||||
|
{"Key":":"}
|
||||||
|
{"Key":"escape"}
|
||||||
|
{"Key":"."}
|
||||||
|
{"Get":{"state":"ˇx hello\n","mode":"Normal"}}
|
Loading…
Add table
Add a link
Reference in a new issue