From d0c2b01b60bbfecdec264c6be0b8208d6ee36909 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Wed, 20 Oct 2021 12:41:55 -0500 Subject: [PATCH] fix #134596 (#135495) --- .../platform/terminal/node/ptyHostService.ts | 8 ++++++-- .../platform/terminal/node/terminalProfiles.ts | 9 +++++++-- .../test/node/terminalProfiles.test.ts | 18 +++++++++--------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/vs/platform/terminal/node/ptyHostService.ts b/src/vs/platform/terminal/node/ptyHostService.ts index f13b62f6ca95..97d8470bad7e 100644 --- a/src/vs/platform/terminal/node/ptyHostService.ts +++ b/src/vs/platform/terminal/node/ptyHostService.ts @@ -48,7 +48,7 @@ export class PtyHostService extends Disposable implements IPtyService { private _restartCount = 0; private _isResponsive = true; private _isDisposed = false; - + private _logIfWslNotInstalled = true; private _heartbeatFirstTimeout?: NodeJS.Timeout; private _heartbeatSecondTimeout?: NodeJS.Timeout; @@ -269,7 +269,11 @@ export class PtyHostService extends Disposable implements IPtyService { } async getProfiles(workspaceId: string, profiles: unknown, defaultProfile: unknown, includeDetectedProfiles: boolean = false): Promise { const shellEnv = await this._shellEnv; - return detectAvailableProfiles(profiles, defaultProfile, includeDetectedProfiles, this._configurationService, shellEnv, undefined, this._logService, this._resolveVariables.bind(this, workspaceId)); + const shouldLog = this._logIfWslNotInstalled; + if (shouldLog) { + this._logIfWslNotInstalled = false; + } + return detectAvailableProfiles(profiles, defaultProfile, includeDetectedProfiles, shouldLog, this._configurationService, shellEnv, undefined, this._logService, this._resolveVariables.bind(this, workspaceId)); } getEnvironment(): Promise { return this._proxy.getEnvironment(); diff --git a/src/vs/platform/terminal/node/terminalProfiles.ts b/src/vs/platform/terminal/node/terminalProfiles.ts index cdb867930e2e..56ef32dff520 100644 --- a/src/vs/platform/terminal/node/terminalProfiles.ts +++ b/src/vs/platform/terminal/node/terminalProfiles.ts @@ -22,12 +22,13 @@ export function detectAvailableProfiles( profiles: unknown, defaultProfile: unknown, includeDetectedProfiles: boolean, + logIfWslNotInstalled: boolean, configurationService: IConfigurationService, shellEnv: typeof process.env = process.env, fsProvider?: IFsProvider, logService?: ILogService, variableResolver?: (text: string[]) => Promise, - testPwshSourcePaths?: string[], + testPwshSourcePaths?: string[] ): Promise { fsProvider = fsProvider || { existsFile: pfs.SymlinkSupport.existsFile, @@ -36,6 +37,7 @@ export function detectAvailableProfiles( if (isWindows) { return detectAvailableWindowsProfiles( includeDetectedProfiles, + logIfWslNotInstalled, fsProvider, shellEnv, logService, @@ -60,6 +62,7 @@ export function detectAvailableProfiles( async function detectAvailableWindowsProfiles( includeDetectedProfiles: boolean, + logIfWslNotInstalled: boolean, fsProvider: IFsProvider, shellEnv: typeof process.env, logService?: ILogService, @@ -130,7 +133,9 @@ async function detectAvailableWindowsProfiles( } } } catch (e) { - logService?.info('WSL is not installed, so could not detect WSL profiles'); + if (logIfWslNotInstalled) { + logService?.info('WSL is not installed, so could not detect WSL profiles'); + } } } diff --git a/src/vs/workbench/contrib/terminal/test/node/terminalProfiles.test.ts b/src/vs/workbench/contrib/terminal/test/node/terminalProfiles.test.ts index 2b2f7100ae10..9fb5b8be803e 100644 --- a/src/vs/workbench/contrib/terminal/test/node/terminalProfiles.test.ts +++ b/src/vs/workbench/contrib/terminal/test/node/terminalProfiles.test.ts @@ -45,7 +45,7 @@ suite('Workbench - TerminalProfiles', () => { useWslProfiles: false }; const configurationService = new TestConfigurationService({ terminal: { integrated: config } }); - const profiles = await detectAvailableProfiles(undefined, undefined, false, configurationService, process.env, fsProvider, undefined, undefined, undefined); + const profiles = await detectAvailableProfiles(undefined, undefined, false, true, configurationService, process.env, fsProvider, undefined, undefined, undefined); const expected = [ { profileName: 'Git Bash', path: 'C:\\Program Files\\Git\\bin\\bash.exe', args: ['--login'], isDefault: true } ]; @@ -67,7 +67,7 @@ suite('Workbench - TerminalProfiles', () => { useWslProfiles: false }; const configurationService = new TestConfigurationService({ terminal: { integrated: config } }); - const profiles = await detectAvailableProfiles(undefined, undefined, false, configurationService, process.env, fsProvider, undefined, undefined, pwshSourcePaths); + const profiles = await detectAvailableProfiles(undefined, undefined, false, true, configurationService, process.env, fsProvider, undefined, undefined, pwshSourcePaths); const expected = [ { profileName: 'PowerShell', path: 'C:\\Program Files\\PowerShell\\7\\pwsh.exe', overrideName: true, args: ['-NoProfile'], isDefault: true } ]; @@ -88,7 +88,7 @@ suite('Workbench - TerminalProfiles', () => { useWslProfiles: false }; const configurationService = new TestConfigurationService({ terminal: { integrated: config } }); - const profiles = await detectAvailableProfiles(undefined, undefined, false, configurationService, process.env, fsProvider, undefined, undefined, undefined); + const profiles = await detectAvailableProfiles(undefined, undefined, false, true, configurationService, process.env, fsProvider, undefined, undefined, undefined); const expected = [{ profileName: 'Git Bash', path: 'C:\\Program Files\\Git\\bin\\bash.exe', args: [], isAutoDetected: undefined, overrideName: undefined, isDefault: true }]; profilesEqual(profiles, expected); }); @@ -112,7 +112,7 @@ suite('Workbench - TerminalProfiles', () => { ]; const fsProvider = createFsProvider(pwshSourcePaths); const configurationService = new TestConfigurationService({ terminal: { integrated: pwshSourceConfig } }); - const profiles = await detectAvailableProfiles(undefined, undefined, false, configurationService, process.env, fsProvider, undefined, undefined, pwshSourcePaths); + const profiles = await detectAvailableProfiles(undefined, undefined, false, true, configurationService, process.env, fsProvider, undefined, undefined, pwshSourcePaths); const expected = [ { profileName: 'PowerShell', path: 'C:\\Program Files\\PowerShell\\7\\pwsh.exe', isDefault: true } ]; @@ -127,7 +127,7 @@ suite('Workbench - TerminalProfiles', () => { ]; const fsProvider = createFsProvider(pwshSourcePaths); const configurationService = new TestConfigurationService({ terminal: { integrated: pwshSourceConfig } }); - const profiles = await detectAvailableProfiles(undefined, undefined, false, configurationService, process.env, fsProvider, undefined, undefined, pwshSourcePaths); + const profiles = await detectAvailableProfiles(undefined, undefined, false, true, configurationService, process.env, fsProvider, undefined, undefined, pwshSourcePaths); const expected = [ { profileName: 'PowerShell', path: 'C:\\Program Files\\PowerShell\\7\\pwsh.exe', isDefault: true } ]; @@ -140,7 +140,7 @@ suite('Workbench - TerminalProfiles', () => { ]; const fsProvider = createFsProvider(pwshSourcePaths); const configurationService = new TestConfigurationService({ terminal: { integrated: pwshSourceConfig } }); - const profiles = await detectAvailableProfiles(undefined, undefined, false, configurationService, process.env, fsProvider, undefined, undefined, pwshSourcePaths); + const profiles = await detectAvailableProfiles(undefined, undefined, false, true, configurationService, process.env, fsProvider, undefined, undefined, pwshSourcePaths); strictEqual(profiles.length, 1); strictEqual(profiles[0].profileName, 'PowerShell'); }); @@ -185,7 +185,7 @@ suite('Workbench - TerminalProfiles', () => { '/bin/fakeshell3' ]); const configurationService = new TestConfigurationService({ terminal: { integrated: absoluteConfig } }); - const profiles = await detectAvailableProfiles(undefined, undefined, false, configurationService, process.env, fsProvider, undefined, undefined, undefined); + const profiles = await detectAvailableProfiles(undefined, undefined, false, true, configurationService, process.env, fsProvider, undefined, undefined, undefined); const expected: ITerminalProfile[] = [ { profileName: 'fakeshell1', path: '/bin/fakeshell1', isDefault: true }, { profileName: 'fakeshell3', path: '/bin/fakeshell3', isDefault: true } @@ -198,7 +198,7 @@ suite('Workbench - TerminalProfiles', () => { '/bin/fakeshell3' ], '/bin/fakeshell1\n/bin/fakeshell3'); const configurationService = new TestConfigurationService({ terminal: { integrated: onPathConfig } }); - const profiles = await detectAvailableProfiles(undefined, undefined, true, configurationService, process.env, fsProvider, undefined, undefined, undefined); + const profiles = await detectAvailableProfiles(undefined, undefined, true, true, configurationService, process.env, fsProvider, undefined, undefined, undefined); const expected: ITerminalProfile[] = [ { profileName: 'fakeshell1', path: 'fakeshell1', isDefault: true }, { profileName: 'fakeshell3', path: 'fakeshell3', isDefault: true } @@ -211,7 +211,7 @@ suite('Workbench - TerminalProfiles', () => { '/bin/fakeshell1' ], '/bin/fakeshell1\n/bin/fakeshell3'); const configurationService = new TestConfigurationService({ terminal: { integrated: onPathConfig } }); - const profiles = await detectAvailableProfiles(undefined, undefined, true, configurationService, process.env, fsProvider, undefined, undefined, undefined); + const profiles = await detectAvailableProfiles(undefined, undefined, true, true, configurationService, process.env, fsProvider, undefined, undefined, undefined); const expected: ITerminalProfile[] = [ { profileName: 'fakeshell1', path: 'fakeshell1', isDefault: true } ];