From c43969eaeda8bb8455227c6e04dbdb391ec5e7d9 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 11 Dec 2023 16:53:43 -0700 Subject: [PATCH] Uncomment editor event tests --- crates/vim2/src/editor_events.rs | 61 +++++++++++++++++--------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/crates/vim2/src/editor_events.rs b/crates/vim2/src/editor_events.rs index b915bd779ec1df85624aab7c40551b3a353a6d55..0e2a1451fe06f145fc305f04f039eb0b62d17dcc 100644 --- a/crates/vim2/src/editor_events.rs +++ b/crates/vim2/src/editor_events.rs @@ -65,35 +65,40 @@ fn released(entity_id: EntityId, cx: &mut WindowContext) { }); } -// #[cfg(test)] -// mod test { -// use crate::{test::VimTestContext, Vim}; -// use editor::Editor; -// use gpui::{Context, Entity}; -// use language::Buffer; +#[cfg(test)] +mod test { + use crate::{test::VimTestContext, Vim}; + use editor::Editor; + use gpui::{Context, Entity}; + use language::Buffer; -// // regression test for blur called with a different active editor -// #[gpui::test] -// async fn test_blur_focus(cx: &mut gpui::TestAppContext) { -// let mut cx = VimTestContext::new(cx, true).await; + // regression test for blur called with a different active editor + #[gpui::test] + async fn test_blur_focus(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; -// let buffer = cx.build_model(|_| Buffer::new(0, 0, "a = 1\nb = 2\n")); -// let window2 = cx.add_window(|cx| Editor::for_buffer(buffer, None, cx)); -// let editor2 = cx -// .update(|cx| window2.update(cx, |editor, cx| cx.view())) -// .unwrap(); + let buffer = cx.build_model(|_| Buffer::new(0, 0, "a = 1\nb = 2\n")); + let window2 = cx.add_window(|cx| Editor::for_buffer(buffer, None, cx)); + let editor2 = cx + .update(|cx| { + window2.update(cx, |_, cx| { + cx.focus_self(); + cx.view().clone() + }) + }) + .unwrap(); -// cx.update(|cx| { -// let vim = Vim::read(cx); -// assert_eq!( -// vim.active_editor.unwrap().entity_id().unwrap(), -// editor2.entity_id() -// ) -// }); + cx.update(|cx| { + let vim = Vim::read(cx); + assert_eq!( + vim.active_editor.as_ref().unwrap().entity_id(), + editor2.entity_id(), + ) + }); -// // no panic when blurring an editor in a different window. -// cx.update_editor(|editor1, cx| { -// editor1.focus_out(cx.handle().into_any(), cx); -// }); -// } -// } + // no panic when blurring an editor in a different window. + cx.update_editor(|editor1, cx| { + editor1.handle_blur(cx); + }); + } +}