feat: fuzzy file open
This commit is contained in:
parent
d3b6545e7c
commit
f589fc2327
4 changed files with 75 additions and 36 deletions
|
|
@ -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,
|
||||
}
|
||||
})()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue