From c3b08609094a4442d7b7a85a4de89553e4f16c3e Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Tue, 16 Dec 2025 03:25:59 -0800 Subject: [PATCH] Remove CopyAsMarkdown (#44933) Copying rendered markdown doesn't reliably do anything sensible. If we copy text from the middle of a bold section, no formatting is copied. If we copy text at the end, the trailing bold delimiters are copied, resulting in gibberish markdown. Thus even fixing the associated issue (so that leading delimeters are reliably copied) won't consistently produce good results. Also, as the user messages in the agent panel don't render markdown anyway, it seems the most likely use case for copying markdown is inapplicable. Closes #42958 Release Notes: - N/A --- assets/keymaps/default-linux.json | 6 +++--- assets/keymaps/default-macos.json | 2 +- assets/keymaps/default-windows.json | 2 +- crates/markdown/src/markdown.rs | 18 ------------------ 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index bb49582ce0e939a5c43c24862a4e50f9d82125d2..38ef7d092d534163ead569c522227b089f84af99 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -262,9 +262,9 @@ { "context": "AgentPanel > Markdown", "bindings": { - "copy": "markdown::CopyAsMarkdown", - "ctrl-insert": "markdown::CopyAsMarkdown", - "ctrl-c": "markdown::CopyAsMarkdown", + "copy": "markdown::Copy", + "ctrl-insert": "markdown::Copy", + "ctrl-c": "markdown::Copy", }, }, { diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 3c6ec6e0423e5ea254ddcd9690f92ac11e0fa73a..8a0e3dfdcddbd448e6a6b9bf66f3731153208120 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -303,7 +303,7 @@ "context": "AgentPanel > Markdown", "use_key_equivalents": true, "bindings": { - "cmd-c": "markdown::CopyAsMarkdown", + "cmd-c": "markdown::Copy", }, }, { diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index b15313fe75cc1265b5eb0c5560f26e4c148d4336..e344ea356fb171fb07474f498056df73c73d8307 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -265,7 +265,7 @@ "context": "AgentPanel > Markdown", "use_key_equivalents": true, "bindings": { - "ctrl-c": "markdown::CopyAsMarkdown", + "ctrl-c": "markdown::Copy", }, }, { diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 6f4ebe4a91f2cee344c1d82ff70722406251434d..270192107c13e8ddfc5eba1b3e6e8e298b93125a 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -149,8 +149,6 @@ actions!( [ /// Copies the selected text to the clipboard. Copy, - /// Copies the selected text as markdown to the clipboard. - CopyAsMarkdown ] ); @@ -295,14 +293,6 @@ impl Markdown { cx.write_to_clipboard(ClipboardItem::new_string(text)); } - fn copy_as_markdown(&self, _: &mut Window, cx: &mut Context) { - if self.selection.end <= self.selection.start { - return; - } - let text = self.source[self.selection.start..self.selection.end].to_string(); - cx.write_to_clipboard(ClipboardItem::new_string(text)); - } - fn parse(&mut self, cx: &mut Context) { if self.source.is_empty() { return; @@ -1360,14 +1350,6 @@ impl Element for MarkdownElement { } } }); - window.on_action(std::any::TypeId::of::(), { - let entity = self.markdown.clone(); - move |_, phase, window, cx| { - if phase == DispatchPhase::Bubble { - entity.update(cx, move |this, cx| this.copy_as_markdown(window, cx)) - } - } - }); self.paint_mouse_listeners(hitbox, &rendered_markdown.text, window, cx); rendered_markdown.element.paint(window, cx);