fix: Prioritize exact phrase matches and fix case-sensitive search
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -481,6 +481,15 @@ export class SearchEngine {
|
||||
query
|
||||
)
|
||||
|
||||
let bestMatch: SearchMatch | undefined
|
||||
if (
|
||||
matches.length > 0 &&
|
||||
query.getBestStringForExcerpt() &&
|
||||
matches[0].match.toLowerCase() === query.getBestStringForExcerpt()
|
||||
) {
|
||||
bestMatch = matches.shift()
|
||||
}
|
||||
|
||||
const lowerCaseBasename = note.basename.toLowerCase()
|
||||
const titleMatchWord = foundWords.find(word =>
|
||||
lowerCaseBasename.includes(word.toLowerCase())
|
||||
@@ -514,6 +523,10 @@ export class SearchEngine {
|
||||
}
|
||||
}
|
||||
|
||||
if (bestMatch) {
|
||||
matches.unshift(bestMatch)
|
||||
}
|
||||
|
||||
logVerbose(`Matches for note "${note.path}"`, matches)
|
||||
const resultNote: ResultNote = {
|
||||
score: result.score,
|
||||
|
||||
Reference in New Issue
Block a user