fix(addon-search): ignore zero-length matches in reverse regex search

Skip empty regex matches in the reverse path to match forward behavior and
avoid unstable result selection.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Daniel Imms
2026-05-25 17:39:23 -07:00
co-authored by Cursor
parent 11720c9dc3
commit c7baa96f97
+3
View File
@@ -289,6 +289,9 @@ export class SearchEngine {
if (isReverseSearch) {
// This loop will get the resultIndex of the _last_ regex match in the range 0..offset
while (foundTerm = searchRegex.exec(searchStringLine.slice(0, offset))) {
if (foundTerm[0].length === 0) {
continue;
}
resultIndex = searchRegex.lastIndex - foundTerm[0].length;
term = foundTerm[0];
searchRegex.lastIndex -= (term.length - 1);