fix: Entferne führende und nachfolgende Leerzeichen aus dem Text für die Anzeige
Co-authored-by: aider (ollama_chat/qwen3-coder:30b) <aider@aider.chat>
This commit is contained in:
parent
6e46b36e09
commit
63fb412772
1 changed files with 12 additions and 9 deletions
|
|
@ -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 += '<span class="highlight-correct highlight-space">·</span>';
|
||||
} else if (currentText[i] === '\t') {
|
||||
} else if (trimmedText[i] === '\t') {
|
||||
highlightedText += '<span class="highlight-correct highlight-tab">→</span>';
|
||||
} else {
|
||||
highlightedText += `<span class="highlight-correct">${currentText[i]}</span>`;
|
||||
highlightedText += `<span class="highlight-correct">${trimmedText[i]}</span>`;
|
||||
}
|
||||
} else {
|
||||
highlightedText += `<span class="highlight-incorrect">${currentText[i]}</span>`;
|
||||
highlightedText += `<span class="highlight-incorrect">${trimmedText[i]}</span>`;
|
||||
}
|
||||
} else {
|
||||
// Für nicht eingegebene Zeichen: Einrückungen anzeigen
|
||||
if (currentText[i] === ' ') {
|
||||
if (trimmedText[i] === ' ') {
|
||||
highlightedText += '<span class="highlight-space">·</span>';
|
||||
} else if (currentText[i] === '\t') {
|
||||
} else if (trimmedText[i] === '\t') {
|
||||
highlightedText += '<span class="highlight-tab">→</span>';
|
||||
} else {
|
||||
highlightedText += currentText[i];
|
||||
highlightedText += trimmedText[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue