mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Use fzf instead of fuse
This commit is contained in:
6
webview-ui/package-lock.json
generated
6
webview-ui/package-lock.json
generated
@@ -19,6 +19,7 @@
|
|||||||
"debounce": "^2.1.1",
|
"debounce": "^2.1.1",
|
||||||
"fast-deep-equal": "^3.1.3",
|
"fast-deep-equal": "^3.1.3",
|
||||||
"fuse.js": "^7.0.0",
|
"fuse.js": "^7.0.0",
|
||||||
|
"fzf": "^0.5.2",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-remark": "^2.1.0",
|
"react-remark": "^2.1.0",
|
||||||
@@ -7475,6 +7476,11 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fzf": {
|
||||||
|
"version": "0.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/fzf/-/fzf-0.5.2.tgz",
|
||||||
|
"integrity": "sha512-Tt4kuxLXFKHy8KT40zwsUPUkg1CrsgY25FxA2U/j/0WgEDCk3ddc/zLTCCcbSHX9FcKtLuVaDGtGE/STWC+j3Q=="
|
||||||
|
},
|
||||||
"node_modules/gensync": {
|
"node_modules/gensync": {
|
||||||
"version": "1.0.0-beta.2",
|
"version": "1.0.0-beta.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"debounce": "^2.1.1",
|
"debounce": "^2.1.1",
|
||||||
"fast-deep-equal": "^3.1.3",
|
"fast-deep-equal": "^3.1.3",
|
||||||
"fuse.js": "^7.0.0",
|
"fuse.js": "^7.0.0",
|
||||||
|
"fzf": "^0.5.2",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-remark": "^2.1.0",
|
"react-remark": "^2.1.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { mentionRegex } from "../../../src/shared/context-mentions"
|
import { mentionRegex } from "../../../src/shared/context-mentions"
|
||||||
import Fuse from "fuse.js"
|
import { Fzf } from "fzf"
|
||||||
|
|
||||||
export function insertMention(
|
export function insertMention(
|
||||||
text: string,
|
text: string,
|
||||||
@@ -148,19 +148,19 @@ export function getContextMenuOptions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Fuse instance for fuzzy search
|
// Create searchable strings array for fzf
|
||||||
const fuse = new Fuse(queryItems, {
|
const searchableItems = queryItems.map(item => ({
|
||||||
keys: ["value", "label", "description"],
|
original: item,
|
||||||
threshold: 0.6,
|
searchStr: [item.value, item.label, item.description].filter(Boolean).join(' ')
|
||||||
shouldSort: true,
|
}))
|
||||||
isCaseSensitive: false,
|
|
||||||
ignoreLocation: false,
|
// Initialize fzf instance for fuzzy search
|
||||||
minMatchCharLength: 1,
|
const fzf = new Fzf(searchableItems, {
|
||||||
|
selector: item => item.searchStr
|
||||||
})
|
})
|
||||||
|
|
||||||
// Get fuzzy matching items
|
// Get fuzzy matching items
|
||||||
const fuseResults = query ? fuse.search(query) : []
|
const matchingItems = query ? fzf.find(query).map(result => result.item.original) : []
|
||||||
const matchingItems = fuseResults.map(result => result.item)
|
|
||||||
|
|
||||||
// Separate matches by type
|
// Separate matches by type
|
||||||
const fileMatches = matchingItems.filter(item =>
|
const fileMatches = matchingItems.filter(item =>
|
||||||
|
|||||||
Reference in New Issue
Block a user