From 63fb4127722628ce33fae0a0c72ef574bcc24f02 Mon Sep 17 00:00:00 2001 From: jamulix Date: Tue, 21 Oct 2025 17:15:43 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Entferne=20f=C3=BChrende=20und=20nachfol?= =?UTF-8?q?gende=20Leerzeichen=20aus=20dem=20Text=20f=C3=BCr=20die=20Anzei?= =?UTF-8?q?ge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: aider (ollama_chat/qwen3-coder:30b) --- static/js/script.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/static/js/script.js b/static/js/script.js index 04cb3fd..59d3c93 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -116,28 +116,31 @@ document.addEventListener('DOMContentLoaded', function() { const targetElement = document.getElementById('target-text'); let highlightedText = ''; - for (let i = 0; i < currentText.length; i++) { + // Entferne führende und nachfolgende Leerzeichen aus dem aktuellen Text für die Anzeige + const trimmedText = currentText.trim(); + + for (let i = 0; i < trimmedText.length; i++) { if (i < userInput.length) { - if (userInput[i] === currentText[i]) { + if (userInput[i] === trimmedText[i]) { // Für korrekt getippte Leerzeichen und Tabulatoren: sichtbar machen - if (currentText[i] === ' ') { + if (trimmedText[i] === ' ') { highlightedText += '·'; - } else if (currentText[i] === '\t') { + } else if (trimmedText[i] === '\t') { highlightedText += ''; } else { - highlightedText += `${currentText[i]}`; + highlightedText += `${trimmedText[i]}`; } } else { - highlightedText += `${currentText[i]}`; + highlightedText += `${trimmedText[i]}`; } } else { // Für nicht eingegebene Zeichen: Einrückungen anzeigen - if (currentText[i] === ' ') { + if (trimmedText[i] === ' ') { highlightedText += '·'; - } else if (currentText[i] === '\t') { + } else if (trimmedText[i] === '\t') { highlightedText += ''; } else { - highlightedText += currentText[i]; + highlightedText += trimmedText[i]; } } }