From ac476cc02884bf6d3dd52adf67a0c6eb89ab9d0a Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 2 Dec 2025 18:52:09 +0530 Subject: [PATCH] fix: add case insensitive match strategy for find and replace --- core/edit/searchAndReplace/findSearchMatch.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/edit/searchAndReplace/findSearchMatch.ts b/core/edit/searchAndReplace/findSearchMatch.ts index 9093bc27b..dd826985d 100644 --- a/core/edit/searchAndReplace/findSearchMatch.ts +++ b/core/edit/searchAndReplace/findSearchMatch.ts @@ -59,6 +59,25 @@ function trimmedMatch( return null; } +/** + * Case-insensitive matching strategy + */ +function caseInsensitiveMatch( + fileContent: string, + searchContent: string, +): BasicMatchResult | null { + const lowerFileContent = fileContent.toLowerCase(); + const lowerSearchContent = searchContent.toLowerCase(); + const index = lowerFileContent.indexOf(lowerSearchContent); + if (index !== -1) { + return { + startIndex: index, + endIndex: index + searchContent.length, + }; + } + return null; +} + /** * Whitespace-ignored matching strategy * Removes all whitespace from both content and search, then finds the match @@ -284,6 +303,7 @@ function findFuzzyMatch( const matchingStrategies: Array<{ strategy: MatchStrategy; name: string }> = [ { strategy: exactMatch, name: "exactMatch" }, { strategy: trimmedMatch, name: "trimmedMatch" }, + { strategy: caseInsensitiveMatch, name: "caseInsensitiveMatch" }, { strategy: whitespaceIgnoredMatch, name: "whitespaceIgnoredMatch" }, // { strategy: findFuzzyMatch, name: "jaroWinklerFuzzyMatch" }, ];