improve whitespace sensitivity in multiline text matching

This commit is contained in:
Marc Goodner
2024-12-04 07:35:12 -08:00
parent 1ec75e87fc
commit bb7925fe11

View File

@@ -231,10 +231,14 @@ function findTextPosition(content: string, searchText: string): Position {
if (pos === -1) {
throw new Error(`Text not found:\n${searchText}`);
}
// Map back to original content position
const originalPos = content.slice(0, pos).replace(/[ \t]+/g, ' ').length;
const originalEnd = originalPos + searchText.length;
return {
start: pos,
end: pos + searchText.length,
end: originalEnd,
lineNumber: normalized.slice(0, pos).split('\n').length
};
}