From c7baa96f97b09aa4972955916ed189f9f4152d4c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 25 May 2026 17:39:23 -0700 Subject: [PATCH] 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 --- addons/addon-search/src/SearchEngine.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/addon-search/src/SearchEngine.ts b/addons/addon-search/src/SearchEngine.ts index 515720a31..22b3d8d2e 100644 --- a/addons/addon-search/src/SearchEngine.ts +++ b/addons/addon-search/src/SearchEngine.ts @@ -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);