editor: Make buffer search bar capture CopyPath & CopyRelativePath actions (#38645)

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.
This commit is contained in:
Miao
2025-09-22 19:56:40 +03:00
committed by GitHub
parent c88fdaf02d
commit a0514af589
2 changed files with 15 additions and 1 deletions
+4
View File
@@ -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();
}
}
+11 -1
View File
@@ -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| {