Skip to content

fix(file-search): rank exact-term edit target case-insensitively - #218

Open
thejesh23 wants to merge 1 commit into
firecrawl:mainfrom
thejesh23:fix/olovable-005
Open

fix(file-search): rank exact-term edit target case-insensitively#218
thejesh23 wants to merge 1 commit into
firecrawl:mainfrom
thejesh23:fix/olovable-005

Conversation

@thejesh23

Copy link
Copy Markdown

What

Fixes edit-target ranking in performSearch: an exact search-term hit was sometimes left at medium confidence (and outranked by an unrelated line) because the confidence check re-tested the term case-sensitively, while the term itself is matched case-insensitively.

Fixes #217

Root cause

lib/file-search-executor.ts matches terms case-insensitively:

if (line.toLowerCase().includes(term.toLowerCase())) { ... matchedTerm = term; }

but the confidence check re-tested case-sensitively:

if (matchedTerm && line.includes(matchedTerm)) { confidence = 'high'; }
else if (line.includes('function') || line.includes('export') || line.includes('return')) { confidence = 'high'; }

On a casing mismatch the exact-match branch is skipped, so the real target stays medium, while an unrelated line containing return/export/function is promoted to high and sorts above it — pointing selectTargetFile at the wrong line.

Fix

-if (matchedTerm && line.includes(matchedTerm)) {
+if (matchedTerm && line.toLowerCase().includes(matchedTerm.toLowerCase())) {
   confidence = 'high';

Verification

searchTerms: ["Sign Up"] against:

<button>sign up</button>       // the real edit target
// return to sign up page       // unrelated comment
Line Before After
<button>sign up</button> medium high
// return to sign up page high (via return) high

The real target is now correctly ranked high instead of being downgraded below the comment.

…term match

Terms are matched case-insensitively, but the confidence re-check used a
case-sensitive line.includes(matchedTerm). On any casing mismatch the real
edit target stayed 'medium' while an unrelated line containing
return/export/function was promoted to 'high' and sorted above it. Lowercase
both sides so an exact term hit is correctly ranked 'high'.

Fixes firecrawl#217
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

file-search: exact-term edit target mis-ranked due to case-sensitive confidence re-check

1 participant