add suggest setting WindowsExecutableExtensions, default values (#238155)

This commit is contained in:
Megan Rogge
2025-01-17 15:05:33 -06:00
committed by GitHub
parent ff593777e3
commit c2c7ab5a88
3 changed files with 65 additions and 5 deletions

View File

@@ -15,6 +15,8 @@ import { isExecutable } from './helpers/executable';
const isWindows = osIsWindows();
let cachedAvailableCommandsPath: string | undefined;
let cachedWindowsExecutableExtensions: Object | undefined;
const cachedWindowsExecutableExtensionsSettingId = 'terminal.integrated.suggest.windowsExecutableExtensions';
let cachedAvailableCommands: Set<ICompletionResource> | undefined;
const cachedBuiltinCommands: Map<string, ICompletionResource[] | undefined> = new Map();
@@ -110,8 +112,18 @@ export async function activate(context: vscode.ExtensionContext) {
return result.items;
}
}, '/', '\\'));
}
if (isWindows) {
cachedWindowsExecutableExtensions = vscode.workspace.getConfiguration(cachedWindowsExecutableExtensionsSettingId);
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(cachedWindowsExecutableExtensionsSettingId)) {
cachedWindowsExecutableExtensions = vscode.workspace.getConfiguration(cachedWindowsExecutableExtensionsSettingId);
cachedAvailableCommands = undefined;
cachedAvailableCommandsPath = undefined;
}
}));
}
}
/**
* Adjusts the current working directory based on a given prefix if it is a folder.
@@ -221,7 +233,7 @@ async function getCommandsInPath(env: { [key: string]: string | undefined } = pr
const files = await vscode.workspace.fs.readDirectory(fileResource);
for (const [file, fileType] of files) {
const formattedPath = getFriendlyFilePath(vscode.Uri.joinPath(fileResource, file), pathSeparator);
if (!labels.has(file) && fileType !== vscode.FileType.Unknown && fileType !== vscode.FileType.Directory && await isExecutable(formattedPath)) {
if (!labels.has(file) && fileType !== vscode.FileType.Unknown && fileType !== vscode.FileType.Directory && await isExecutable(formattedPath), cachedWindowsExecutableExtensions) {
executables.add({ label: file, path: formattedPath });
labels.add(file);
}