core: keep windows @mentions finding project files
parent
3b32584efa
commit
19a503aa7e
|
|
@ -573,7 +573,8 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||
const pinned: AtOption[] = open.map((path) => ({ type: "file", path, display: path, recent: true }))
|
||||
if (!query.trim()) return [...agents, ...pinned]
|
||||
const pathy = /[./\\]/.test(query)
|
||||
const paths = await files.searchFiles(query)
|
||||
const seek = query.replaceAll("\\", "/")
|
||||
const paths = await files.searchFiles(seek)
|
||||
const fileOptions: AtOption[] = paths
|
||||
.filter((path) => !seen.has(path))
|
||||
.map((path) => ({ type: "file", path, display: path }))
|
||||
|
|
@ -583,6 +584,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||
key: atKey,
|
||||
filterKeys: ["display"],
|
||||
stale: false,
|
||||
fuzzy: (query) => !/[./\\]/.test(query),
|
||||
groupBy: (item) => {
|
||||
if (item.type === "agent") return "agent"
|
||||
if (item.recent) return "recent"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import { afterEach, describe, expect, test } from "bun:test"
|
||||
import fs from "fs/promises"
|
||||
import path from "path"
|
||||
import { tmpdir } from "../fixture/fixture"
|
||||
|
|
@ -10,6 +10,10 @@ async function write(file: string, body: string) {
|
|||
await fs.writeFile(file, body)
|
||||
}
|
||||
|
||||
afterEach(async () => {
|
||||
await Instance.disposeAll()
|
||||
})
|
||||
|
||||
describe("file.fff", () => {
|
||||
test("allowed respects hidden filter", async () => {
|
||||
expect(Fff.allowed({ rel: "visible.txt", hidden: true })).toBe(true)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export interface FilteredListProps<T> {
|
|||
onSelect?: (value: T | undefined, index: number) => void
|
||||
noInitialSelection?: boolean
|
||||
stale?: boolean
|
||||
fuzzy?: boolean | ((filter: string) => boolean)
|
||||
}
|
||||
|
||||
export function useFilteredList<T>(props: FilteredListProps<T>) {
|
||||
|
|
@ -31,11 +32,12 @@ export function useFilteredList<T>(props: FilteredListProps<T>) {
|
|||
async ({ filter, items }) => {
|
||||
const query = filter ?? ""
|
||||
const needle = query.toLowerCase()
|
||||
const fuzzy = typeof props.fuzzy === "function" ? props.fuzzy(query) : (props.fuzzy ?? true)
|
||||
const all = (await Promise.resolve(items)) || []
|
||||
const result = pipe(
|
||||
all,
|
||||
(x) => {
|
||||
if (!needle) return x
|
||||
if (!needle || !fuzzy) return x
|
||||
if (!props.filterKeys && Array.isArray(x) && x.every((e) => typeof e === "string")) {
|
||||
return fuzzysort.go(needle, x).map((x) => x.target) as T[]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue