mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -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",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"fuse.js": "^7.0.0",
|
||||
"fzf": "^0.5.2",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-remark": "^2.1.0",
|
||||
@@ -7475,6 +7476,11 @@
|
||||
"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": {
|
||||
"version": "1.0.0-beta.2",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"debounce": "^2.1.1",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"fuse.js": "^7.0.0",
|
||||
"fzf": "^0.5.2",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-remark": "^2.1.0",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { mentionRegex } from "../../../src/shared/context-mentions"
|
||||
import Fuse from "fuse.js"
|
||||
import { Fzf } from "fzf"
|
||||
|
||||
export function insertMention(
|
||||
text: string,
|
||||
@@ -148,19 +148,19 @@ export function getContextMenuOptions(
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize Fuse instance for fuzzy search
|
||||
const fuse = new Fuse(queryItems, {
|
||||
keys: ["value", "label", "description"],
|
||||
threshold: 0.6,
|
||||
shouldSort: true,
|
||||
isCaseSensitive: false,
|
||||
ignoreLocation: false,
|
||||
minMatchCharLength: 1,
|
||||
// Create searchable strings array for fzf
|
||||
const searchableItems = queryItems.map(item => ({
|
||||
original: item,
|
||||
searchStr: [item.value, item.label, item.description].filter(Boolean).join(' ')
|
||||
}))
|
||||
|
||||
// Initialize fzf instance for fuzzy search
|
||||
const fzf = new Fzf(searchableItems, {
|
||||
selector: item => item.searchStr
|
||||
})
|
||||
|
||||
// Get fuzzy matching items
|
||||
const fuseResults = query ? fuse.search(query) : []
|
||||
const matchingItems = fuseResults.map(result => result.item)
|
||||
const matchingItems = query ? fzf.find(query).map(result => result.item.original) : []
|
||||
|
||||
// Separate matches by type
|
||||
const fileMatches = matchingItems.filter(item =>
|
||||
|
||||
Reference in New Issue
Block a user