@: directories complete, not just files

walk({includeDirs}) yields src/ and src/ui/ with trailing slash, only
on the @ path. matchPaths ranks dirs before files for the same prefix
so @src/ surfaces the directory itself. Insertion keeps the slash.
This commit is contained in:
asepharyana committed 2026-09-09 13:55:02 +07:00
1 parent 5028ea6973
commit 4b4ddd0585
5 files changed
+96 -10

No files matched your search

+6
View File
@@ -88,6 +88,8 @@ export type WalkOptions = {
root?: string;
/** Include files git would ignore. */
noIgnore?: boolean;
/** Also yield directories (with trailing `/`), so `@` can complete to them. */
includeDirs?: boolean;
limit?: number;
};
@@ -130,6 +132,10 @@ export async function* walk(options: WalkOptions = {}): AsyncGenerator<string> {
if (!options.noIgnore && ignored(rel, entry.isDirectory, rules)) continue;
if (entry.isDirectory) {
if (options.includeDirs) {
yield `${rel}/`;
if (++yielded >= limit) return;
}
// A symlinked directory is not descended into: it can point anywhere,
// including back into the tree.
if (entry.isLink) continue;