From c485a03946d5c67933ec1f66c99edc2f58edab93 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Sun, 5 Apr 2026 20:22:44 +0200 Subject: [PATCH] fix(web): preserve newlines in code copy-paste Append a \n text node inside each .line span so copy-pasting from the code block includes proper line breaks. Co-Authored-By: Claude Opus 4.6 (1M context) --- webui2/src/components/code/file-viewer.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webui2/src/components/code/file-viewer.tsx b/webui2/src/components/code/file-viewer.tsx index 41514cf392655e450ea0a4bf7894897968682294..0177d3a6942e86f4e5f58f7f122ccdc5a09020dd 100644 --- a/webui2/src/components/code/file-viewer.tsx +++ b/webui2/src/components/code/file-viewer.tsx @@ -95,6 +95,9 @@ function lineNumberTransformer(): ShikiTransformer { return { line(node, line) { node.properties["dataLineNumber"] = line; + // Append a \n text node inside each .line so copy-paste preserves newlines + // (we strip the inter-element whitespace nodes in code() below). + node.children.push({ type: "text", value: "\n" }); }, // Remove whitespace text nodes between .line spans — they create // empty anonymous table rows when using display: table-row.