Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/3 Code Health/6912.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove try...catch around use of vscode.env.shell
12 changes: 3 additions & 9 deletions src/client/common/application/applicationEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { inject, injectable } from 'inversify';
import * as path from 'path';
import { parse } from 'semver';
import * as vscode from 'vscode';
import { traceError } from '../logger';
import { IPlatformService } from '../platform/types';
import { ICurrentProcess, IPathUtils } from '../types';
import { OSType } from '../utils/platform';
Expand Down Expand Up @@ -57,16 +56,11 @@ export class ApplicationEnvironment implements IApplicationEnvironment {
* unstable API.
* Solution - log and suppress the errors.
* @readonly
* @type {(string | undefined)}
* @type {(string)}
* @memberof ApplicationEnvironment
*/
public get shell(): string | undefined {
try {
// tslint:disable-next-line:no-any
return (vscode.env as any).shell;
} catch (error) {
traceError('Unable to determine shell using VS Code API.', error);
}
public get shell(): string {
return vscode.env.shell;
}
// tslint:disable-next-line:no-any
public get packageJson(): any {
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ export interface IApplicationEnvironment {
* @type {string}
* @memberof IApplicationShell
*/
readonly shell: string | undefined;
readonly shell: string;
/**
* Gets the vscode channel (whether 'insiders' or 'stable').
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ suite('Shell Detectors', () => {
expect(shellDetector.identify(telemetryProperties, { name: shellPath } as any)).to.equal(shellType, `Incorrect Shell Type from identifyShellByTerminalName, for path '${shellPath}'`);
});

when(appEnv.shell).thenReturn(undefined);
when(appEnv.shell).thenReturn(undefined as any);
expect(shellDetector.identify(telemetryProperties, undefined)).to.equal(undefined, 'Should be undefined when vscode.env.shell is undefined');
});
test('Identify shell based on VSC Settings', async () => {
Expand Down