Ignore bg terminals for confirmOnExit

Fixes #235575
pull/236588/head
Daniel Imms 2024-12-19 05:10:51 -08:00
parent 7efdaa5e8e
commit 05519998ae
No known key found for this signature in database
GPG Key ID: E5CF412B63651C69
2 changed files with 8 additions and 4 deletions

View File

@ -95,6 +95,10 @@ export class TerminalService extends Disposable implements ITerminalService {
get instances(): ITerminalInstance[] {
return this._terminalGroupService.instances.concat(this._terminalEditorService.instances).concat(this._backgroundedTerminalInstances);
}
/** Gets all non-background terminals. */
get foregroundInstances(): ITerminalInstance[] {
return this._terminalGroupService.instances.concat(this._terminalEditorService.instances);
}
get detachedInstances(): Iterable<IDetachedTerminalInstance> {
return this._detachedXterms;
}
@ -417,7 +421,6 @@ export class TerminalService extends Disposable implements ITerminalService {
if (instance.target !== TerminalLocation.Editor &&
instance.hasChildProcesses &&
(this._terminalConfigurationService.config.confirmOnKill === 'panel' || this._terminalConfigurationService.config.confirmOnKill === 'always')) {
const veto = await this._showTerminalCloseConfirmation(true);
if (veto) {
return;
@ -904,10 +907,11 @@ export class TerminalService extends Disposable implements ITerminalService {
protected async _showTerminalCloseConfirmation(singleTerminal?: boolean): Promise<boolean> {
let message: string;
if (this.instances.length === 1 || singleTerminal) {
const foregroundInstances = this.foregroundInstances;
if (foregroundInstances.length === 1 || singleTerminal) {
message = nls.localize('terminalService.terminalCloseConfirmationSingular', "Do you want to terminate the active terminal session?");
} else {
message = nls.localize('terminalService.terminalCloseConfirmationPlural', "Do you want to terminate the {0} active terminal sessions?", this.instances.length);
message = nls.localize('terminalService.terminalCloseConfirmationPlural', "Do you want to terminate the {0} active terminal sessions?", foregroundInstances.length);
}
const { confirmed } = await this._dialogService.confirm({
type: 'warning',

View File

@ -366,7 +366,7 @@ const terminalConfiguration: IConfigurationNode = {
default: 'never'
},
[TerminalSettingId.ConfirmOnKill]: {
description: localize('terminal.integrated.confirmOnKill', "Controls whether to confirm killing terminals when they have child processes. When set to editor, terminals in the editor area will be marked as changed when they have child processes. Note that child process detection may not work well for shells like Git Bash which don't run their processes as child processes of the shell."),
description: localize('terminal.integrated.confirmOnKill', "Controls whether to confirm killing terminals when they have child processes. When set to editor, terminals in the editor area will be marked as changed when they have child processes. Note that child process detection may not work well for shells like Git Bash which don't run their processes as child processes of the shell. Background terminals like those launched by some extensions will not trigger the confirmation."),
type: 'string',
enum: ['never', 'editor', 'panel', 'always'],
enumDescriptions: [