The best way to control Claude Code, Codex and more from any computer or phone
fix(web): stop wrapping partial code block selections in markdown fences (#5069)
Tai Nguyen committed
Aug 15, 2026 at 19:06 UTC
c4556ab237515cea8ec6f482351c58da730ad495
1 file changed
+11
apps/web/src/markdown-clipboard.ts
+11
@@ -301,6 +301,17 @@ export function chatMarkdownClipboardPayload(
301
if (range.collapsed) continue;
302
const container = document.createElement("div");
303
container.appendChild(range.cloneContents());
304
+ const ancestor = range.commonAncestorContainer;
305
+ const ancestorElement =
306
+ ancestor.nodeType === Node.ELEMENT_NODE ? (ancestor as Element) : ancestor.parentElement;
307
+ if (ancestorElement?.closest("pre")) {
308
+ const text = range.toString();
309
+ if (text) {
310
+ texts.push(text);
311
+ htmls.push(sanitizedHtmlFrom(container));
312
+ }
313
+ continue;
314
+ }
315
const text = serializeRenderedMarkdownFragment(container);
316
if (!text) continue;
317
texts.push(text);