diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.ts b/src/vs/workbench/contrib/terminal/browser/terminal.ts index a74f1024b79ec..1dcaecd333a0d 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.ts @@ -690,6 +690,7 @@ export interface ITerminalInstance extends IBaseTerminalInstance { onDidExecuteText: Event; onDidChangeTarget: Event; onDidSendText: Event; + onDidChangeShellType: Event; /** * An event that fires when a terminal is dropped on this instance via drag and drop. diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 70bd126a25899..63899c8c3c60b 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -341,6 +341,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { readonly onDidChangeTarget = this._onDidChangeTarget.event; private readonly _onDidSendText = this._register(new Emitter()); readonly onDidSendText = this._onDidSendText.event; + private readonly _onDidChangeShellType = this._register(new Emitter()); + readonly onDidChangeShellType = this._onDidChangeShellType.event; constructor( private readonly _terminalShellTypeContextKey: IContextKey, @@ -1896,9 +1898,13 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { } setShellType(shellType: TerminalShellType | undefined) { - this._shellType = shellType; + if (this._shellType === shellType) { + return; + } if (shellType) { + this._shellType = shellType; this._terminalShellTypeContextKey.set(shellType?.toString()); + this._onDidChangeShellType.fire(shellType); } } diff --git a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminal.suggest.contribution.ts b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminal.suggest.contribution.ts index 7a781570251a5..ab39f57b9e9d9 100644 --- a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminal.suggest.contribution.ts +++ b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminal.suggest.contribution.ts @@ -5,6 +5,7 @@ import type { Terminal as RawXtermTerminal } from '@xterm/xterm'; import * as dom from 'vs/base/browser/dom'; +import { Event } from 'vs/base/common/event'; import { KeyCode } from 'vs/base/common/keyCodes'; import { DisposableStore, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { localize2 } from 'vs/nls'; @@ -39,7 +40,7 @@ class TerminalSuggestContribution extends DisposableStore implements ITerminalCo constructor( private readonly _instance: ITerminalInstance, - _processManager: ITerminalProcessManager, + processManager: ITerminalProcessManager, widgetManager: TerminalWidgetManager, @IContextKeyService private readonly _contextKeyService: IContextKeyService, @IConfigurationService private readonly _configurationService: IConfigurationService, @@ -51,7 +52,9 @@ class TerminalSuggestContribution extends DisposableStore implements ITerminalCo } xtermOpen(xterm: IXtermTerminal & { raw: RawXtermTerminal }): void { - this._loadSuggestAddon(xterm.raw); + this.add(Event.runAndSubscribe(this._instance.onDidChangeShellType, async () => { + this._loadSuggestAddon(xterm.raw); + })); this.add(this._contextKeyService.onDidChangeContext(e => { if (e.affectsSome(this._terminalSuggestWidgetContextKeys)) { this._loadSuggestAddon(xterm.raw); @@ -66,8 +69,8 @@ class TerminalSuggestContribution extends DisposableStore implements ITerminalCo private _loadSuggestAddon(xterm: RawXtermTerminal): void { const sendingKeybindingsToShell = this._configurationService.getValue(TERMINAL_CONFIG_SECTION).sendKeybindingsToShell; - if (sendingKeybindingsToShell) { - this._addon.dispose(); + if (sendingKeybindingsToShell || this._instance.shellType !== 'pwsh') { + this._addon.clear(); return; } if (this._terminalSuggestWidgetVisibleContextKey) {