Skip to content

Commit fbf10f5

Browse files
committed
fix: add shell type to setup providers
1 parent 33d458b commit fbf10f5

7 files changed

Lines changed: 21 additions & 9 deletions

File tree

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { PythonProjectManagerImpl } from './features/projectManager';
4545
import { getPythonApi, setPythonApi } from './features/pythonApi';
4646
import { registerCompletionProvider } from './features/settings/settingCompletions';
4747
import { setActivateMenuButtonContext } from './features/terminal/activateMenuButton';
48-
import { ShellStartupActivationManagerImpl } from './features/terminal/shells/activateUsingShellStartup';
48+
import { ShellStartupActivationManagerImpl } from './features/terminal/activateUsingShellStartup';
4949
import { normalizeShellPath } from './features/terminal/shells/common/shellUtils';
5050
import { createShellEnvProviders, createShellStartupProviders } from './features/terminal/shells/providers';
5151
import { TerminalActivationImpl } from './features/terminal/terminalActivationState';

src/features/terminal/activateUsingShellStartup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ export class ShellStartupActivationManagerImpl implements ShellStartupActivation
2424
) {
2525
this.envCollection.description = ShellStartupActivationStrings.envCollectionDescription;
2626
this.disposables.push(
27-
onDidChangeConfiguration((e: ConfigurationChangeEvent) => {
28-
this.handleConfigurationChange(e);
27+
onDidChangeConfiguration(async (e: ConfigurationChangeEvent) => {
28+
await this.handleConfigurationChange(e);
2929
}),
30-
this.em.onDidChangeEnvironmentFiltered((e: DidChangeEnvironmentEventArgs) => {
31-
this.handleEnvironmentChange(e);
30+
this.em.onDidChangeEnvironmentFiltered(async (e: DidChangeEnvironmentEventArgs) => {
31+
await this.handleEnvironmentChange(e);
3232
}),
3333
);
3434
}

src/features/terminal/shells/bash/bashStartup.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import * as fs from 'fs-extra';
2-
import * as path from 'path';
32
import * as os from 'os';
4-
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
5-
import { traceError, traceInfo, traceVerbose } from '../../../../common/logging';
3+
import * as path from 'path';
64
import which from 'which';
7-
import { BASH_ENV_KEY, ZSH_ENV_KEY } from './bashConstants';
5+
import { traceError, traceInfo, traceVerbose } from '../../../../common/logging';
6+
import { ShellConstants } from '../../../common/shellConstants';
87
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
8+
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
9+
import { BASH_ENV_KEY, ZSH_ENV_KEY } from './bashConstants';
910

1011
async function isBashLikeInstalled(): Promise<boolean> {
1112
const result = await Promise.all([which('bash', { nothrow: true }), which('sh', { nothrow: true })]);
@@ -106,6 +107,7 @@ async function removeStartup(profile: string, key: string): Promise<boolean> {
106107

107108
export class BashStartupProvider implements ShellStartupScriptProvider {
108109
public readonly name: string = 'Bash';
110+
public readonly shellType: string = ShellConstants.BASH;
109111

110112
private async checkShellInstalled(): Promise<boolean> {
111113
const found = await isBashLikeInstalled();
@@ -168,6 +170,7 @@ export class BashStartupProvider implements ShellStartupScriptProvider {
168170

169171
export class ZshStartupProvider implements ShellStartupScriptProvider {
170172
public readonly name: string = 'Zsh';
173+
public readonly shellType: string = ShellConstants.ZSH;
171174

172175
private async checkShellInstalled(): Promise<boolean> {
173176
const found = await isZshInstalled();
@@ -225,6 +228,7 @@ export class ZshStartupProvider implements ShellStartupScriptProvider {
225228

226229
export class GitBashStartupProvider implements ShellStartupScriptProvider {
227230
public readonly name: string = 'GitBash';
231+
public readonly shellType: string = ShellConstants.GITBASH;
228232

229233
private async checkShellInstalled(): Promise<boolean> {
230234
const found = await isGitBashInstalled();

src/features/terminal/shells/cmd/cmdStartup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { promisify } from 'util';
66
import which from 'which';
77
import { traceError, traceInfo, traceVerbose } from '../../../../common/logging';
88
import { isWindows } from '../../../../common/utils/platformUtils';
9+
import { ShellConstants } from '../../../common/shellConstants';
910
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
1011
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
1112
import { CMD_ENV_KEY } from './cmdConstants';
@@ -256,6 +257,7 @@ async function removeCmdStartup(startupFile: string, key: string): Promise<boole
256257

257258
export class CmdStartupProvider implements ShellStartupScriptProvider {
258259
public readonly name: string = 'Command Prompt';
260+
public readonly shellType: string = ShellConstants.CMD;
259261

260262
async isSetup(): Promise<ShellSetupState> {
261263
const isInstalled = await isCmdInstalled();

src/features/terminal/shells/fish/fishStartup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as path from 'path';
44
import which from 'which';
55

66
import { traceError, traceInfo, traceVerbose } from '../../../../common/logging';
7+
import { ShellConstants } from '../../../common/shellConstants';
78
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
89
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
910
import { FISH_ENV_KEY } from './fishConstants';
@@ -90,6 +91,7 @@ async function removeFishStartup(profilePath: string, key: string): Promise<bool
9091

9192
export class FishStartupProvider implements ShellStartupScriptProvider {
9293
public readonly name: string = 'Fish';
94+
public readonly shellType: string = ShellConstants.FISH;
9395

9496
async isSetup(): Promise<ShellSetupState> {
9597
const isInstalled = await isFishInstalled();

src/features/terminal/shells/pwsh/pwshStartup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { isWindows } from '../../../../common/utils/platformUtils';
77
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
88
import { runCommand } from '../utils';
99

10+
import { ShellConstants } from '../../../common/shellConstants';
1011
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
1112
import { POWERSHELL_ENV_KEY } from './pwshConstants';
1213

@@ -133,6 +134,7 @@ async function removePowerShellStartup(shell: string, profile: string): Promise<
133134

134135
export class PowerShellClassicStartupProvider implements ShellStartupScriptProvider {
135136
public readonly name: string = 'PowerShell5';
137+
public readonly shellType: string = 'powershell';
136138

137139
async isSetup(): Promise<ShellSetupState> {
138140
const isInstalled = await isPowerShellInstalled('powershell');
@@ -188,6 +190,7 @@ export class PowerShellClassicStartupProvider implements ShellStartupScriptProvi
188190

189191
export class PwshStartupProvider implements ShellStartupScriptProvider {
190192
public readonly name: string = 'PowerShell';
193+
public readonly shellType: string = ShellConstants.PWSH;
191194

192195
async isSetup(): Promise<ShellSetupState> {
193196
const isInstalled = await isPowerShellInstalled('pwsh');

src/features/terminal/shells/startupProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export enum ShellScriptEditState {
1515

1616
export interface ShellStartupScriptProvider {
1717
name: string;
18+
readonly shellType: string;
1819
isSetup(): Promise<ShellSetupState>;
1920
setupScripts(): Promise<ShellScriptEditState>;
2021
teardownScripts(): Promise<ShellScriptEditState>;

0 commit comments

Comments
 (0)