Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Fix `editor: copy path` not working in SSH remoting (#23235)
CharlesChen0823f0a07b5effcd
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 111231bf1e1..1212084b067 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -11471,6 +11471,24 @@ impl Editor {.and_then(|f| f.as_local())}+ fn target_file_abs_path(&self, cx: &mut ViewContext<Self>) -> Option<PathBuf> {+ self.active_excerpt(cx).and_then(|(_, buffer, _)| {+ let project_path = buffer.read(cx).project_path(cx)?;+ let project = self.project.as_ref()?.read(cx);+ project.absolute_path(&project_path, cx)+ })+ }++ fn target_file_path(&self, cx: &mut ViewContext<Self>) -> Option<PathBuf> {+ self.active_excerpt(cx).and_then(|(_, buffer, _)| {+ let project_path = buffer.read(cx).project_path(cx)?;+ let project = self.project.as_ref()?.read(cx);+ let entry = project.entry_for_path(&project_path, cx)?;+ let path = entry.path.to_path_buf();+ Some(path)+ })+ }+pub fn reveal_in_finder(&mut self, _: &RevealInFileManager, cx: &mut ViewContext<Self>) {if let Some(target) = self.target_file(cx) {cx.reveal_path(&target.abs_path(cx));@@ -11478,16 +11496,16 @@ impl Editor {}pub fn copy_path(&mut self, _: &CopyPath, cx: &mut ViewContext<Self>) {- if let Some(file) = self.target_file(cx) {- if let Some(path) = file.abs_path(cx).to_str() {+ if let Some(path) = self.target_file_abs_path(cx) {+ if let Some(path) = path.to_str() {cx.write_to_clipboard(ClipboardItem::new_string(path.to_string()));}}}pub fn copy_relative_path(&mut self, _: &CopyRelativePath, cx: &mut ViewContext<Self>) {- if let Some(file) = self.target_file(cx) {- if let Some(path) = file.path().to_str() {+ if let Some(path) = self.target_file_path(cx) {+ if let Some(path) = path.to_str() {cx.write_to_clipboard(ClipboardItem::new_string(path.to_string()));}}