From 9b7528855850b3e70dc53186808a0918922e66f2 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 13:06:31 -0400 Subject: [PATCH] Project Search: Don't prompt to save edited buffers in project search results if buffers open elsewhere (cherry-pick #31026) (#31028) Cherry-picked Project Search: Don't prompt to save edited buffers in project search results if buffers open elsewhere (#31026) Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored-by: Ben Kunkle --- crates/search/src/project_search.rs | 11 +++++++++-- crates/workspace/src/pane.rs | 11 ++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 06cd5664bf41ae8a03efcaf7c5f442e4a6652aa0..f60cb645b36906560c1b4a4f04f2e878b15e10e4 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -1055,10 +1055,17 @@ impl ProjectSearchView { let is_dirty = self.is_dirty(cx); - let should_confirm_save = !will_autosave && is_dirty; + let skip_save_on_close = self + .workspace + .read_with(cx, |workspace, cx| { + workspace::Pane::skip_save_on_close(&self.results_editor, workspace, cx) + }) + .unwrap_or(false); + + let should_prompt_to_save = !skip_save_on_close && !will_autosave && is_dirty; cx.spawn_in(window, async move |this, cx| { - let should_search = if should_confirm_save { + let should_search = if should_prompt_to_save { let options = &["Save", "Don't Save", "Cancel"]; let result_channel = this.update_in(cx, |_, window, cx| { window.prompt( diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index e1f03dee555173eb523069bc765637675e8dc03d..0a8dd5de666490a4c225231b91bcd12630b3e9da 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1440,10 +1440,7 @@ impl Pane { } }); if dirty_project_item_ids.is_empty() { - if item.is_singleton(cx) && item.is_dirty(cx) { - return false; - } - return true; + return !(item.is_singleton(cx) && item.is_dirty(cx)); } for open_item in workspace.items(cx) { @@ -1456,11 +1453,7 @@ impl Pane { let other_project_item_ids = open_item.project_item_model_ids(cx); dirty_project_item_ids.retain(|id| !other_project_item_ids.contains(id)); } - if dirty_project_item_ids.is_empty() { - return true; - } - - false + return dirty_project_item_ids.is_empty(); } pub(super) fn file_names_for_prompt(