fix: Korrigiere Texthervorhebung für Leerzeichen und Tabulatoren in der Vorlage
Co-authored-by: aider (ollama_chat/qwen3-coder:30b) <aider@aider.chat>
This commit is contained in:
parent
63fb412772
commit
9802c90c5b
1 changed files with 12 additions and 12 deletions
|
|
@ -116,31 +116,31 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
const targetElement = document.getElementById('target-text');
|
||||
let highlightedText = '';
|
||||
|
||||
// Entferne führende und nachfolgende Leerzeichen aus dem aktuellen Text für die Anzeige
|
||||
const trimmedText = currentText.trim();
|
||||
// Verwende den ursprünglichen Text für die Anzeige, nicht den trimmten
|
||||
const originalText = currentText;
|
||||
|
||||
for (let i = 0; i < trimmedText.length; i++) {
|
||||
for (let i = 0; i < originalText.length; i++) {
|
||||
if (i < userInput.length) {
|
||||
if (userInput[i] === trimmedText[i]) {
|
||||
if (userInput[i] === originalText[i]) {
|
||||
// Für korrekt getippte Leerzeichen und Tabulatoren: sichtbar machen
|
||||
if (trimmedText[i] === ' ') {
|
||||
highlightedText += '<span class="highlight-correct highlight-space">·</span>';
|
||||
} else if (trimmedText[i] === '\t') {
|
||||
if (originalText[i] === ' ') {
|
||||
highlightedText += '<span class="highlight-ccorrect highlight-space">·</span>';
|
||||
} else if (originalText[i] === '\t') {
|
||||
highlightedText += '<span class="highlight-correct highlight-tab">→</span>';
|
||||
} else {
|
||||
highlightedText += `<span class="highlight-correct">${trimmedText[i]}</span>`;
|
||||
highlightedText += `<span class="highlight-correct">${originalText[i]}</span>`;
|
||||
}
|
||||
} else {
|
||||
highlightedText += `<span class="highlight-incorrect">${trimmedText[i]}</span>`;
|
||||
highlightedText += `<span class="highlight-incorrect">${originalText[i]}</span>`;
|
||||
}
|
||||
} else {
|
||||
// Für nicht eingegebene Zeichen: Einrückungen anzeigen
|
||||
if (trimmedText[i] === ' ') {
|
||||
if (originalText[i] === ' ') {
|
||||
highlightedText += '<span class="highlight-space">·</span>';
|
||||
} else if (trimmedText[i] === '\t') {
|
||||
} else if (originalText[i] === '\t') {
|
||||
highlightedText += '<span class="highlight-tab">→</span>';
|
||||
} else {
|
||||
highlightedText += trimmedText[i];
|
||||
highlightedText += originalText[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue