From eb7154d099a8fd503b0260a7c89422d6e0e97bdb Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 9 Sep 2025 22:53:03 +0300 Subject: [PATCH] Skip "open this directory" menu entry in case of errors (#37872) Follow-up of https://github.com/zed-industries/zed/pull/37564 Release Notes: - N/A --- crates/file_finder/src/open_path_prompt.rs | 9 +++++---- crates/file_finder/src/open_path_prompt_tests.rs | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/file_finder/src/open_path_prompt.rs b/crates/file_finder/src/open_path_prompt.rs index c0abb372b28ff817853e9dc7b6523f676359e157..ab00f943b811a941f7339853a79f81dfea5275eb 100644 --- a/crates/file_finder/src/open_path_prompt.rs +++ b/crates/file_finder/src/open_path_prompt.rs @@ -392,10 +392,11 @@ impl PickerDelegate for OpenPathDelegate { let should_prepend_with_current_dir = this .read_with(cx, |picker, _| { !input_is_empty - && !matches!( - picker.delegate.directory_state, - DirectoryState::Create { .. } - ) + && match &picker.delegate.directory_state { + DirectoryState::List { error, .. } => error.is_none(), + DirectoryState::Create { .. } => false, + DirectoryState::None { .. } => false, + } }) .unwrap_or(false); if should_prepend_with_current_dir { diff --git a/crates/file_finder/src/open_path_prompt_tests.rs b/crates/file_finder/src/open_path_prompt_tests.rs index 1f47c4e80adc598c505cf130519623fd6e578035..fd7cc1c6c612d28b1cc8f2352f6dbb0a254e7e98 100644 --- a/crates/file_finder/src/open_path_prompt_tests.rs +++ b/crates/file_finder/src/open_path_prompt_tests.rs @@ -39,6 +39,9 @@ async fn test_open_path_prompt(cx: &mut TestAppContext) { let (picker, cx) = build_open_path_prompt(project, false, PathStyle::current(), cx); + insert_query(path!("sadjaoislkdjasldj"), &picker, cx).await; + assert_eq!(collect_match_candidates(&picker, cx), Vec::::new()); + let query = path!("/root"); insert_query(query, &picker, cx).await; assert_eq!(collect_match_candidates(&picker, cx), vec!["root"]);