mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
Merge branch 'tyriar/258512__259342' into tyriar/258512__259342__259339
This commit is contained in:
@@ -103,6 +103,7 @@ export class PathExecutableCache implements vscode.Disposable {
|
||||
// Extract executables from PATH
|
||||
const paths = pathValue.split(isWindows ? ';' : ':');
|
||||
const pathSeparator = isWindows ? '\\' : '/';
|
||||
const promisePaths: string[] = [];
|
||||
const promises: Promise<Set<ICompletionResource> | undefined>[] = [];
|
||||
const labels: Set<string> = new Set<string>();
|
||||
|
||||
@@ -116,6 +117,7 @@ export class PathExecutableCache implements vscode.Disposable {
|
||||
}
|
||||
} else {
|
||||
// Not cached, need to scan this directory
|
||||
promisePaths.push(pathDir);
|
||||
promises.push(this._getExecutablesInSinglePath(pathDir, pathSeparator, labels));
|
||||
}
|
||||
}
|
||||
@@ -123,11 +125,9 @@ export class PathExecutableCache implements vscode.Disposable {
|
||||
// Process uncached directories
|
||||
if (promises.length > 0) {
|
||||
const resultSets = await Promise.all(promises);
|
||||
let uncachedPathIndex = 0;
|
||||
|
||||
for (const pathDir of paths) {
|
||||
for (const [i, resultSet] of resultSets.entries()) {
|
||||
const pathDir = promisePaths[i];
|
||||
if (!this._cachedExes.has(pathDir)) {
|
||||
const resultSet = resultSets[uncachedPathIndex++];
|
||||
this._cachedExes.set(pathDir, resultSet || new Set());
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,12 @@ export class PathExecutableCache implements vscode.Disposable {
|
||||
|
||||
// Merge all results from all directories
|
||||
const executables = new Set<ICompletionResource>();
|
||||
const processedPaths: Set<string> = new Set();
|
||||
for (const pathDir of paths) {
|
||||
if (processedPaths.has(pathDir)) {
|
||||
continue;
|
||||
}
|
||||
processedPaths.add(pathDir);
|
||||
const dirExecutables = this._cachedExes.get(pathDir);
|
||||
if (dirExecutables) {
|
||||
for (const executable of dirExecutables) {
|
||||
|
||||
@@ -252,13 +252,9 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
const [commandsInPath, shellGlobals] = await Promise.all([
|
||||
pathExecutableCache.getExecutablesInPath(terminal.shellIntegration?.env?.value, terminalShellType),
|
||||
(async () => {
|
||||
const executables = await pathExecutableCache.getExecutablesInPath(terminal.shellIntegration?.env?.value, terminalShellType);
|
||||
return getShellGlobals(terminalShellType, executables?.labels, machineId, remoteAuthority);
|
||||
})()
|
||||
]);
|
||||
const commandsInPath = await pathExecutableCache.getExecutablesInPath(terminal.shellIntegration?.env?.value, terminalShellType);
|
||||
const shellGlobals = await getShellGlobals(terminalShellType, commandsInPath?.labels, machineId, remoteAuthority);
|
||||
|
||||
const shellGlobalsArr = shellGlobals ?? [];
|
||||
if (!commandsInPath?.completionResources) {
|
||||
console.debug('#terminalCompletions No commands found in path');
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'mocha';
|
||||
import { strictEqual } from 'node:assert';
|
||||
import { deepStrictEqual, strictEqual } from 'node:assert';
|
||||
import type { MarkdownString } from 'vscode';
|
||||
import { PathExecutableCache } from '../../env/pathExecutableCache';
|
||||
|
||||
@@ -16,12 +16,12 @@ suite('PathExecutableCache', () => {
|
||||
strictEqual(Array.from(result!.labels!).length, 0);
|
||||
});
|
||||
|
||||
test('caching is working on successive calls', async () => {
|
||||
test('results are the same on successive calls', async () => {
|
||||
const cache = new PathExecutableCache();
|
||||
const env = { PATH: process.env.PATH };
|
||||
const result = await cache.getExecutablesInPath(env);
|
||||
const result2 = await cache.getExecutablesInPath(env);
|
||||
strictEqual(result, result2);
|
||||
deepStrictEqual(result!.labels, result2!.labels);
|
||||
});
|
||||
|
||||
test('refresh clears the cache', async () => {
|
||||
|
||||
Reference in New Issue
Block a user