Skip to content

Commit

Permalink
[vscode] Skip hidden files without file extensions when detecting lan…
Browse files Browse the repository at this point in the history
…guages
  • Loading branch information
chanhx committed Jun 2, 2023
1 parent f57e034 commit 82ddcb4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions editors/code/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,26 @@ async function collectFileExtensions(
token: vscode.CancellationToken
) {
let files: vscode.Uri[];
let exclude = undefined;

let paths = scanDirectories.map(dir => dir.length > 0 ? `${dir}/**/*.*` : `**/*.*`);
const include = new vscode.RelativePattern(folder, `{${paths.join(',')}}`);
let hiddenFiles = [];

while (true) {
exclude = `{${Array.from(extensions).concat(ignoredExtensions).map(ext => `**/*.${ext}`).concat(ignores).join(',')}}`;
let exclude = `{${Array.from(extensions).concat(ignoredExtensions).map(ext => `**/*.${ext}`).concat(ignores).concat(hiddenFiles).join(',')}}`;

files = await vscode.workspace.findFiles(include, exclude, 1, token);
if (files.length <= 0 || token.isCancellationRequested) {
break;
}

const ext = path.extname(files[0].path).substring(1);
extensions.add(ext);
if (ext.length > 0) {
extensions.add(ext);
} else {
let relativePath = path.relative(folder.uri.path, files[0].path);
hiddenFiles.push(relativePath);
}
}
}

Expand Down

0 comments on commit 82ddcb4

Please sign in to comment.