diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index daf7b938e4..a9bdd7288d 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -87,7 +87,14 @@ impl FileFinder { workspace.register_action( |workspace, action: &workspace::ToggleFileFinder, window, cx| { let Some(file_finder) = workspace.active_modal::(cx) else { - Self::open(workspace, action.separate_history, window, cx).detach(); + Self::open( + workspace, + action.separate_history, + action.include_ignored, + window, + cx, + ) + .detach(); return; }; @@ -104,6 +111,7 @@ impl FileFinder { fn open( workspace: &mut Workspace, separate_history: bool, + include_ignored: Option, window: &mut Window, cx: &mut Context, ) -> Task<()> { @@ -156,6 +164,7 @@ impl FileFinder { currently_opened_path, history_items.collect(), separate_history, + include_ignored, window, cx, ); @@ -953,6 +962,7 @@ impl FileFinderDelegate { currently_opened_path: Option, history_items: Vec, separate_history: bool, + include_ignored: Option, window: &mut Window, cx: &mut Context, ) -> Self { @@ -982,7 +992,7 @@ impl FileFinderDelegate { separate_history, first_update: true, focus_handle: cx.focus_handle(), - include_ignored: FileFinderSettings::get_global(cx).include_ignored, + include_ignored: include_ignored.or(FileFinderSettings::get_global(cx).include_ignored), include_ignored_refresh: Task::ready(()), } } diff --git a/crates/file_finder/src/file_finder_tests.rs b/crates/file_finder/src/file_finder_tests.rs index e83d7db791..ec49c8a373 100644 --- a/crates/file_finder/src/file_finder_tests.rs +++ b/crates/file_finder/src/file_finder_tests.rs @@ -1094,6 +1094,48 @@ async fn test_ignored_root_with_file_inclusions_repro(cx: &mut TestAppContext) { }); } +#[gpui::test] +async fn test_toggle_action_include_ignored_param(cx: &mut TestAppContext) { + let app_state = init_test(cx); + let project = Project::test(app_state.fs.clone(), [], cx).await; + let (multi_workspace, cx) = + cx.add_window_view(|window, cx| MultiWorkspace::test_new(project, window, cx)); + let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); + + let cases = [ + (None, Some(true), Some(true)), + (None, Some(false), Some(false)), + (None, None, None), + (Some(true), Some(false), Some(false)), + (Some(false), Some(true), Some(true)), + (Some(true), None, Some(true)), + ]; + for (setting, action_param, expected) in cases { + cx.update(|_, cx| { + let settings = *FileFinderSettings::get_global(cx); + FileFinderSettings::override_global( + FileFinderSettings { + include_ignored: setting, + ..settings + }, + cx, + ); + }); + cx.dispatch_action(ToggleFileFinder { + separate_history: false, + include_ignored: action_param, + }); + let picker = active_file_picker(&workspace, cx); + picker.update(cx, |picker, _| { + assert_eq!( + picker.delegate.include_ignored, expected, + "setting: {setting:?}, action param: {action_param:?}" + ); + }); + cx.dispatch_action(menu::Cancel); + } +} + #[gpui::test] async fn test_ignored_root(cx: &mut TestAppContext) { let app_state = init_test(cx); @@ -4513,6 +4555,7 @@ pub(crate) fn open_file_picker( ) -> Entity> { cx.dispatch_action(ToggleFileFinder { separate_history: true, + include_ignored: None, }); active_file_picker(workspace, cx) } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index b93e8a64bf..e91019f6ca 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -481,6 +481,8 @@ actions!( pub struct ToggleFileFinder { #[serde(default)] pub separate_history: bool, + #[serde(default)] + pub include_ignored: Option, } /// Opens a new terminal in the center.