Fix opening GoToLine from Command

This was broken because of the async hop introduced by should_dismiss.

Change that API to instead be syncronous, and require that implementors
(of which there is only one) to call dismiss again if they want to.
This commit is contained in:
Conrad Irwin 2023-12-12 20:30:30 -07:00
parent c9aa4a0e00
commit a2f0accb74
6 changed files with 70 additions and 36 deletions

View file

@ -28,6 +28,8 @@ gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
editor = { package = "editor2", path = "../editor2", features = ["test-support"] }
language = { package="language2", path = "../language2", features = ["test-support"] }
project = { package="project2", path = "../project2", features = ["test-support"] }
menu = { package = "menu2", path = "../menu2" }
go_to_line = { package = "go_to_line2", path = "../go_to_line2" }
serde_json.workspace = true
workspace = { package="workspace2", path = "../workspace2", features = ["test-support"] }
ctor.workspace = true

View file

@ -360,6 +360,7 @@ mod tests {
use super::*;
use editor::Editor;
use go_to_line::GoToLine;
use gpui::TestAppContext;
use project::Project;
use workspace::{AppState, Workspace};
@ -383,7 +384,6 @@ mod tests {
#[gpui::test]
async fn test_command_palette(cx: &mut TestAppContext) {
let app_state = init_test(cx);
let project = Project::test(app_state.fs.clone(), [], cx).await;
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project.clone(), cx));
@ -453,12 +453,29 @@ mod tests {
});
}
#[gpui::test]
async fn test_go_to_line(cx: &mut TestAppContext) {
let app_state = init_test(cx);
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_input("go to line: Toggle");
cx.simulate_keystrokes("enter");
workspace.update(cx, |workspace, cx| {
assert!(workspace.active_modal::<GoToLine>(cx).is_some())
})
}
fn init_test(cx: &mut TestAppContext) -> Arc<AppState> {
cx.update(|cx| {
let app_state = AppState::test(cx);
theme::init(theme::LoadThemes::JustBase, cx);
language::init(cx);
editor::init(cx);
menu::init();
go_to_line::init(cx);
workspace::init(app_state.clone(), cx);
init(cx);
Project::init_settings(cx);