fix: Korrigiere Anzeige von Tabulatoren in der Texthervorhebung
Co-authored-by: aider (ollama_chat/qwen3-coder:30b) <aider@aider.chat>
This commit is contained in:
parent
8e3c80b724
commit
604c4de290
1 changed files with 13 additions and 10 deletions
|
|
@ -116,31 +116,34 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
const targetElement = document.getElementById('target-text');
|
||||
let highlightedText = '';
|
||||
|
||||
// Verwende den ursprünglichen Text für die Anzeige, nicht den trimmten
|
||||
// Verwende den ursprünglichen Text für die Anzeige
|
||||
const originalText = currentText;
|
||||
|
||||
for (let i = 0; i < originalText.length; i++) {
|
||||
// Erstelle eine Kopie des Textes für die Anzeige, um Tabulatoren korrekt zu behandeln
|
||||
let displayText = originalText;
|
||||
|
||||
for (let i = 0; i < displayText.length; i++) {
|
||||
if (i < userInput.length) {
|
||||
if (userInput[i] === originalText[i]) {
|
||||
if (userInput[i] === displayText[i]) {
|
||||
// Für korrekt getippte Leerzeichen und Tabulatoren: sichtbar machen
|
||||
if (originalText[i] === ' ') {
|
||||
if (displayText[i] === ' ') {
|
||||
highlightedText += '<span class="highlight-correct highlight-space">·</span>';
|
||||
} else if (originalText[i] === '\t') {
|
||||
} else if (displayText[i] === '\t') {
|
||||
highlightedText += '<span class="highlight-correct highlight-tab">→</span>';
|
||||
} else {
|
||||
highlightedText += `<span class="highlight-correct">${originalText[i]}</span>`;
|
||||
highlightedText += `<span class="highlight-correct">${displayText[i]}</span>`;
|
||||
}
|
||||
} else {
|
||||
highlightedText += `<span class="highlight-incorrect">${originalText[i]}</span>`;
|
||||
highlightedText += `<span class="highlight-incorrect">${displayText[i]}</span>`;
|
||||
}
|
||||
} else {
|
||||
// Für nicht eingegebene Zeichen: Einrückungen anzeigen
|
||||
if (originalText[i] === ' ') {
|
||||
if (displayText[i] === ' ') {
|
||||
highlightedText += '<span class="highlight-space">·</span>';
|
||||
} else if (originalText[i] === '\t') {
|
||||
} else if (displayText[i] === '\t') {
|
||||
highlightedText += '<span class="highlight-tab">→</span>';
|
||||
} else {
|
||||
highlightedText += originalText[i];
|
||||
highlightedText += displayText[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue