From 12708746496225474c020218d3eae298977266f5 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:43:35 -0800 Subject: [PATCH] Suppress exit warning after ctrl+d Fixes #160325 --- src/vs/workbench/contrib/terminal/browser/terminal.ts | 5 +++++ .../workbench/contrib/terminal/browser/terminalInstance.ts | 2 +- .../contrib/terminal/browser/xterm/xtermTerminal.ts | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.ts b/src/vs/workbench/contrib/terminal/browser/terminal.ts index 2a56aeca979..ead75598c0e 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.ts @@ -1095,6 +1095,11 @@ export interface IXtermTerminal extends IDisposable { */ readonly isGpuAccelerated: boolean; + /** + * The last `onData` input event fired by {@link RawXtermTerminal.onData}. + */ + readonly lastInputEvent: string | undefined; + /** * Attached the terminal to the given element * @param container Container the terminal will be rendered in diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 0a1646792a0..df286dd974a 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1598,7 +1598,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { } else { if (exitMessage) { const failedDuringLaunch = this._processManager.processState === ProcessState.KilledDuringLaunch; - if (failedDuringLaunch || this._terminalConfigurationService.config.showExitAlert) { + if (failedDuringLaunch || (this._terminalConfigurationService.config.showExitAlert && this.xterm?.lastInputEvent !== /*Ctrl+D*/'\x04')) { // Always show launch failures this._notificationService.notify({ message: exitMessage, diff --git a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts index 5ef6d497196..4e860821f7e 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts @@ -96,6 +96,8 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach private static _suggestedRendererType: 'dom' | undefined = undefined; private _attached?: { container: HTMLElement; options: IXtermAttachToElementOptions }; private _isPhysicalMouseWheel = MouseWheelClassifier.INSTANCE.isPhysicalMouseWheel(); + private _lastInputEvent: string | undefined; + get lastInputEvent(): string | undefined { return this._lastInputEvent; } // Always on addons private _markNavigationAddon: MarkNavigationAddon; @@ -256,6 +258,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach this._anyFocusedTerminalHasSelection.set(this.raw.hasSelection()); } })); + this._register(this.raw.onData(e => this._lastInputEvent = e)); // Load addons this._updateUnicodeVersion();