feat: fuzzy file open

This commit is contained in:
Adam 2025-09-24 12:40:54 -05:00
commit f589fc2327
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
4 changed files with 75 additions and 36 deletions

View file

@ -163,7 +163,7 @@ function init() {
})
}
const open = async (path: string) => {
const open = async (path: string, options?: { pin?: boolean }) => {
const relative = path.replace(sync.data.path.directory + "/", "")
if (!store.node[relative]) {
const parent = relative.split("/").slice(0, -1).join("/")
@ -181,6 +181,7 @@ function init() {
]
})
setStore("active", relative)
if (options?.pin) setStore("node", path, "pinned", true)
if (store.node[relative].loaded) return
return load(relative)
}
@ -199,6 +200,8 @@ function init() {
})
}
const search = (query: string) => sdk.find.files({ query: { query } }).then((x) => x.data!)
const bus = useEvent()
bus.listen((event) => {
switch (event.type) {
@ -303,6 +306,7 @@ function init() {
!x.path.replace(new RegExp(`^${path + "/"}`), "").includes("/"),
)
},
search,
}
})()