From 555e5b30bef360e7f10debc0c2fdf6c6962c1b01 Mon Sep 17 00:00:00 2001 From: fen Date: Thu, 10 Sep 2026 13:12:52 -0500 Subject: [PATCH] Fix #205: guard splitLines() when server HTML has no newlines so renumber runs --- internal/web/static/paste-lines.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/web/static/paste-lines.js b/internal/web/static/paste-lines.js index 41537f9..aacab75 100644 --- a/internal/web/static/paste-lines.js +++ b/internal/web/static/paste-lines.js @@ -20,6 +20,13 @@ // box per line, which would shift every following number down one row (#167). function splitLines() { var html = body.innerHTML; + if (html.indexOf('\n') < 0) { + // No newline text nodes to split on (already joined in the server + // template or stripped upstream): blocks are already adjacent, so + // leave the DOM alone. Splitting here would clone the whole markup + // into one block and leave renumber() reading stale nodes (#205). + return; + } var parts = html.split('\n'); var out = []; for (var i = 0; i < parts.length; i++) {