From b37c1a94beb35d8dedf2961967728e10098be5ca Mon Sep 17 00:00:00 2001 From: kgva CMS Date: Mon, 10 Aug 2026 21:11:30 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20prompt=20line=20still=20wraps+overlaps?= =?UTF-8?q?=20on=20long=20ghost=20text=20=E2=80=94=20hard-clip=20from=20fr?= =?UTF-8?q?ont=20in=20JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/shell.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/assets/js/shell.js b/assets/js/shell.js index 59f39e1..9824bdd 100644 --- a/assets/js/shell.js +++ b/assets/js/shell.js @@ -15,6 +15,25 @@ // right so the left (older) part clips off terminal-style instead of wrapping. function keepEnd() { if (promptEl) promptEl.scrollLeft = promptEl.scrollWidth; } + // hard guarantee: the prompt is ALWAYS one line. CSS (nowrap + overflow:hidden) + // is normally enough, but a long ghost command (long path + filename) can still + // force the line to wrap on some viewports/browsers, which then bugs out the + // layout below it. so on top of the CSS, actually shorten the text in the DOM: + // clip from the FRONT (oldest part, same side as the terminal-scroll above) and + // mark the cut with "…" — the leading verb ("cat "/"cd ") is allowed to go first. + function fitOneLine(text) { + if (!promptEl) return text; + promptEl.scrollLeft = 0; // measure from a clean, unscrolled state + input.textContent = text; + if (promptEl.scrollWidth <= promptEl.clientWidth) return text; + var shown = text; + while (shown.length > 1 && promptEl.scrollWidth > promptEl.clientWidth) { + shown = shown.slice(1); + input.textContent = "…" + shown; + } + return input.textContent; + } + var home = bar.getAttribute("data-home") || "/"; // command → url: the always-open menu, plus any context routes (e.g. the @@ -45,7 +64,7 @@ var ghostActive = false; function setGhost(text) { if (!ghostActive && input.textContent) return; // never clobber a real command in progress - input.textContent = text; + fitOneLine(text); ghostActive = true; input.classList.add("is-ghost"); caretToEnd();