fix: Correct match offset when ignoring diacritics

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-02-13 16:46:25 -07:00
parent b6f98f5d04
commit bb58c12306
+10 -3
View File
@@ -84,9 +84,16 @@ export class TextProcessor {
} }
const matchStartIndex = match.index const matchStartIndex = match.index
const matchEndIndex = matchStartIndex + match[0].length const matchEndIndex = matchStartIndex + match[0].length
const originalMatch = originalText
.substring(matchStartIndex, matchEndIndex) // If `ignoreDiacritics` is on, `text` may have a different length than `originalText`,
.trim() // making `match.index` unreliable for `originalText`.
// We use `match[0]`, which is the matched term (but without diacritics).
const originalMatchBeforeTrim = this.plugin.settings.ignoreDiacritics
? match[0]
: originalText.substring(matchStartIndex, matchEndIndex)
const originalMatch = originalMatchBeforeTrim.trim()
if (originalMatch && match.index >= 0) { if (originalMatch && match.index >= 0) {
matches.push({ match: originalMatch, offset: match.index }) matches.push({ match: originalMatch, offset: match.index })
} }