chore: generate
This commit is contained in:
parent
b1a6c40ad0
commit
89e371c94b
2 changed files with 31 additions and 39 deletions
|
|
@ -133,10 +133,7 @@ function item(hit: Fff.Hit): Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectPaths<T>(
|
function collectPaths<T>(items: T[], toPath: (item: T) => string): string[] {
|
||||||
items: T[],
|
|
||||||
toPath: (item: T) => string,
|
|
||||||
): string[] {
|
|
||||||
return Array.from(
|
return Array.from(
|
||||||
new Set(
|
new Set(
|
||||||
items.flatMap((item): string[] => {
|
items.flatMap((item): string[] => {
|
||||||
|
|
|
||||||
|
|
@ -367,40 +367,39 @@ export function createPromptState(input: PromptInput): PromptState {
|
||||||
|
|
||||||
const next = extractLineRange(value)
|
const next = extractLineRange(value)
|
||||||
const list = await input.findFiles(next.base)
|
const list = await input.findFiles(next.base)
|
||||||
return list
|
return list.map((item): Auto => {
|
||||||
.map((item): Auto => {
|
const url = pathToFileURL(path.resolve(input.directory, item))
|
||||||
const url = pathToFileURL(path.resolve(input.directory, item))
|
let filename = item
|
||||||
let filename = item
|
if (next.line && !item.endsWith("/")) {
|
||||||
if (next.line && !item.endsWith("/")) {
|
filename = `${item}#${next.line.start}${next.line.end ? `-${next.line.end}` : ""}`
|
||||||
filename = `${item}#${next.line.start}${next.line.end ? `-${next.line.end}` : ""}`
|
url.searchParams.set("start", String(next.line.start))
|
||||||
url.searchParams.set("start", String(next.line.start))
|
if (next.line.end !== undefined) {
|
||||||
if (next.line.end !== undefined) {
|
url.searchParams.set("end", String(next.line.end))
|
||||||
url.searchParams.set("end", String(next.line.end))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
kind: "mention",
|
kind: "mention",
|
||||||
display: Locale.truncateMiddle("@" + filename, width()),
|
display: Locale.truncateMiddle("@" + filename, width()),
|
||||||
value: filename,
|
value: filename,
|
||||||
directory: item.endsWith("/"),
|
directory: item.endsWith("/"),
|
||||||
part: {
|
part: {
|
||||||
|
type: "file",
|
||||||
|
mime: item.endsWith("/") ? "application/x-directory" : "text/plain",
|
||||||
|
filename,
|
||||||
|
url: url.href,
|
||||||
|
source: {
|
||||||
type: "file",
|
type: "file",
|
||||||
mime: item.endsWith("/") ? "application/x-directory" : "text/plain",
|
path: item,
|
||||||
filename,
|
text: {
|
||||||
url: url.href,
|
start: 0,
|
||||||
source: {
|
end: 0,
|
||||||
type: "file",
|
value: "",
|
||||||
path: item,
|
|
||||||
text: {
|
|
||||||
start: 0,
|
|
||||||
end: 0,
|
|
||||||
value: "",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
})
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
{ initialValue: [] as Auto[] },
|
{ initialValue: [] as Auto[] },
|
||||||
)
|
)
|
||||||
|
|
@ -462,13 +461,9 @@ export function createPromptState(input: PromptInput): PromptState {
|
||||||
const next = removeLineRange(query())
|
const next = removeLineRange(query())
|
||||||
if (mode() === "mention") {
|
if (mode() === "mention") {
|
||||||
return [
|
return [
|
||||||
...fuzzysort
|
...fuzzysort.go(next, agents(), { keys: ["value", "display", "description"] }).map((item) => item.obj),
|
||||||
.go(next, agents(), { keys: ["value", "display", "description"] })
|
|
||||||
.map((item) => item.obj),
|
|
||||||
...files(),
|
...files(),
|
||||||
...fuzzysort
|
...fuzzysort.go(next, resources(), { keys: ["value", "display", "description"] }).map((item) => item.obj),
|
||||||
.go(next, resources(), { keys: ["value", "display", "description"] })
|
|
||||||
.map((item) => item.obj),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue