Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add command to copy current file:line for working with external tools (#14793)
Scott Lembckee2635a685ed3
diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rsindex 3fa241676fe..e0ae75b6361 100644--- a/crates/editor/src/actions.rs+++ b/crates/editor/src/actions.rs@@ -199,6 +199,7 @@ gpui::actions!(CopyHighlightJson,CopyPath,CopyPermalinkToLine,+ CopyFileLocation,CopyRelativePath,Cut,CutToEndOfLine,diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex a3cfc5a2878..a458660185d 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -10905,6 +10905,17 @@ impl Editor {}}+ pub fn copy_file_location(&mut self, _: &CopyFileLocation, cx: &mut ViewContext<Self>) {+ if let Some(buffer) = self.buffer().read(cx).as_singleton() {+ if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) {+ if let Some(path) = file.path().to_str() {+ let selection = self.selections.newest::<Point>(cx).start.row + 1;+ cx.write_to_clipboard(ClipboardItem::new_string(format!("{path}:{selection}")));+ }+ }+ }+ }+pub fn open_permalink_to_line(&mut self, _: &OpenPermalinkToLine, cx: &mut ViewContext<Self>) {let permalink = self.get_permalink_to_line(cx);diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex c1ebdea5e2a..0126f3491da 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -353,6 +353,7 @@ impl EditorElement {register_action(view, cx, Editor::copy_highlight_json);register_action(view, cx, Editor::copy_permalink_to_line);register_action(view, cx, Editor::open_permalink_to_line);+ register_action(view, cx, Editor::copy_file_location);register_action(view, cx, Editor::toggle_git_blame);register_action(view, cx, Editor::toggle_git_blame_inline);register_action(view, cx, Editor::toggle_hunk_diff);