From 979db25e91b6c861372253298c2f3fb93641239d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 12 Dec 2023 20:53:54 -0700 Subject: [PATCH] Extend test to cover go_to_line behavior too (It's also been broken and fixed a few times along the way) --- .../command_palette2/src/command_palette.rs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/command_palette2/src/command_palette.rs b/crates/command_palette2/src/command_palette.rs index e795c38bc8..58a6760e72 100644 --- a/crates/command_palette2/src/command_palette.rs +++ b/crates/command_palette2/src/command_palette.rs @@ -362,6 +362,7 @@ mod tests { use editor::Editor; use go_to_line::GoToLine; use gpui::TestAppContext; + use language::Point; use project::Project; use workspace::{AppState, Workspace}; @@ -459,13 +460,30 @@ mod tests { let project = Project::test(app_state.fs.clone(), [], cx).await; let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project.clone(), cx)); - cx.simulate_keystrokes("cmd-n cmd-shift-p"); + cx.simulate_keystrokes("cmd-n"); + + let editor = workspace.update(cx, |workspace, cx| { + workspace.active_item_as::(cx).unwrap() + }); + editor.update(cx, |editor, cx| editor.set_text("1\n2\n3\n4\n5\n6\n", cx)); + + cx.simulate_keystrokes("cmd-shift-p"); cx.simulate_input("go to line: Toggle"); cx.simulate_keystrokes("enter"); workspace.update(cx, |workspace, cx| { assert!(workspace.active_modal::(cx).is_some()) - }) + }); + + cx.simulate_keystrokes("3 enter"); + + editor.update(cx, |editor, cx| { + assert!(editor.focus_handle(cx).is_focused(cx)); + assert_eq!( + editor.selections.last::(cx).range().start, + Point::new(2, 0) + ); + }); } fn init_test(cx: &mut TestAppContext) -> Arc {