Skip to content

Commit b390127

Browse files
authored
Exclude folders in files.exclude from activating (#1642)
Use glob approach and exclude those patterns Issue: #1641
1 parent 324f291 commit b390127

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/utilities/workspace.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import * as vscode from "vscode";
1616
import { pathExists } from "./filesystem";
17+
import { convertPathToPattern, glob } from "fast-glob";
18+
import { basename } from "path";
1719

1820
export async function searchForPackages(
1921
folder: vscode.Uri,
@@ -32,14 +34,16 @@ export async function searchForPackages(
3234
return;
3335
}
3436

35-
await vscode.workspace.fs.readDirectory(folder).then(async entries => {
37+
const config = vscode.workspace.getConfiguration("files");
38+
const vscodeExcludeList = config.get<{ [key: string]: boolean }>("exclude", {});
39+
await glob(`${convertPathToPattern(folder.fsPath)}/*`, {
40+
ignore: [...Object.keys(vscodeExcludeList).filter(k => vscodeExcludeList[k])],
41+
absolute: true,
42+
onlyDirectories: true,
43+
}).then(async entries => {
3644
for (const entry of entries) {
37-
if (
38-
entry[1] === vscode.FileType.Directory &&
39-
entry[0][0] !== "." &&
40-
entry[0] !== "Packages"
41-
) {
42-
await search(vscode.Uri.joinPath(folder, entry[0]));
45+
if (basename(entry) !== "." && basename(entry) !== "Packages") {
46+
await search(vscode.Uri.file(entry));
4347
}
4448
}
4549
});

0 commit comments

Comments
 (0)