diff --git a/assets/js/shell.js b/assets/js/shell.js index 9824bdd..55fe07e 100644 --- a/assets/js/shell.js +++ b/assets/js/shell.js @@ -21,13 +21,27 @@ // 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. + // + // the lang-switch (de/en) is position:absolute top-right over the same row — + // CSS reserves padding-right for it, but that padding doesn't actually stop + // overflowing nowrap text (padding isn't a layout barrier for overflow), so a + // long enough line still slides under it. check the real rendered edges too, + // not just clientWidth, so the toggle at the far end is never covered. + function overlapsLangSwitch() { + var ls = document.querySelector(".lang-switch"); + if (!ls) return false; + var lsRect = ls.getBoundingClientRect(); + var inRect = input.getBoundingClientRect(); + return inRect.right > lsRect.left - 8; // 8px breathing room + } + function fits() { return promptEl.scrollWidth <= promptEl.clientWidth && !overlapsLangSwitch(); } 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; + if (fits()) return text; var shown = text; - while (shown.length > 1 && promptEl.scrollWidth > promptEl.clientWidth) { + while (shown.length > 1 && !fits()) { shown = shown.slice(1); input.textContent = "…" + shown; }