From a0514af58955a21401b4c10918a45c9c241a4a74 Mon Sep 17 00:00:00 2001 From: Miao Date: Tue, 23 Sep 2025 00:56:40 +0800 Subject: [PATCH] editor: Make buffer search bar capture CopyPath & CopyRelativePath actions (#38645) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #38495 Cause: - When the Find input is focused, CopyPath/CopyRelativePath were handled by the editor and stopped during the bubble phase, preventing BufferSearchBar from relaying to the file-backed editor. Release Notes: - Fixes “Workspace: Copy Relative Path” not copying while the Find bar is focused. --- crates/editor/src/editor.rs | 4 ++++ crates/search/src/buffer_search.rs | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index fbf70322b890ab9a2a3c1f9e915a5debae2e4e64..38ebdb4909b051d96700447617b392a7741714a7 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -19308,6 +19308,8 @@ impl Editor { && let Some(path) = path.to_str() { cx.write_to_clipboard(ClipboardItem::new_string(path.to_string())); + } else { + cx.propagate(); } } @@ -19321,6 +19323,8 @@ impl Editor { && let Some(path) = path.to_str() { cx.write_to_clipboard(ClipboardItem::new_string(path.to_string())); + } else { + cx.propagate(); } } diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index dd096cde851b21983be80c5ce64b78338f54d78e..925d390cb3eb5489025818e4826aba691ac1bfa8 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -28,7 +28,7 @@ use schemars::JsonSchema; use serde::Deserialize; use settings::Settings; use std::sync::Arc; -use zed_actions::outline::ToggleOutline; +use zed_actions::{outline::ToggleOutline, workspace::CopyPath, workspace::CopyRelativePath}; use ui::{ BASE_REM_SIZE_IN_PX, IconButton, IconButtonShape, IconName, Tooltip, h_flex, prelude::*, @@ -425,6 +425,16 @@ impl Render for BufferSearchBar { active_searchable_item.relay_action(Box::new(ToggleOutline), window, cx); } })) + .on_action(cx.listener(|this, _: &CopyPath, window, cx| { + if let Some(active_searchable_item) = &mut this.active_searchable_item { + active_searchable_item.relay_action(Box::new(CopyPath), window, cx); + } + })) + .on_action(cx.listener(|this, _: &CopyRelativePath, window, cx| { + if let Some(active_searchable_item) = &mut this.active_searchable_item { + active_searchable_item.relay_action(Box::new(CopyRelativePath), window, cx); + } + })) .when(replacement, |this| { this.on_action(cx.listener(Self::toggle_replace)) .when(in_replace, |this| {