Expand confirmOnExit setting to allow always or only on child proc

Fixes #23808
This commit is contained in:
Daniel Imms 2021-07-15 05:01:14 -07:00
parent 62cc852c02
commit e6b92dece2
3 changed files with 12 additions and 6 deletions

View file

@ -487,7 +487,11 @@ export class TerminalService implements ITerminalService {
}
const shouldPersistTerminals = this._configHelper.config.enablePersistentSessions && reason === ShutdownReason.RELOAD;
if (this.configHelper.config.confirmOnExit && !shouldPersistTerminals && this.instances.some(e => e.hasChildProcesses)) {
const hasDirtyInstances = (
(this.configHelper.config.confirmOnExit === 'always' && this.instances.length > 0) ||
(this.configHelper.config.confirmOnExit === 'hasChildProcesses' && this.instances.some(e => e.hasChildProcesses))
);
if (!shouldPersistTerminals && hasDirtyInstances) {
return this._onBeforeShutdownAsync();
}

View file

@ -172,7 +172,8 @@ export interface ITerminalProfiles {
windows: { [key: string]: ITerminalProfileObject };
}
export type ConfirmOnKill = 'off' | 'editor' | 'panel' | 'editorAndPanel';
export type ConfirmOnKill = 'never' | 'editor' | 'panel' | 'editorAndPanel';
export type ConfirmOnExit = 'never' | 'always' | 'hasChildProcesses';
export interface ITerminalConfiguration {
shell: {
@ -223,7 +224,7 @@ export interface ITerminalConfiguration {
allowChords: boolean;
allowMnemonics: boolean;
cwd: string;
confirmOnExit: boolean;
confirmOnExit: ConfirmOnExit;
confirmOnKill: ConfirmOnKill;
enableBell: boolean;
env: {

View file

@ -266,14 +266,15 @@ const terminalConfiguration: IConfigurationNode = {
default: undefined
},
[TerminalSettingId.ConfirmOnExit]: {
description: localize('terminal.integrated.confirmOnExit', "Controls whether to confirm on exit if there are active terminal sessions with child processes."),
type: 'boolean',
description: localize('terminal.integrated.confirmOnExit', "Controls whether to confirm on exit if there are active terminal sessions."),
type: 'string',
enum: ['never', 'always', 'hasChildProcesses'],
default: false
},
[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 dirty when they have child processes."),
type: 'string',
enum: ['off', 'editor', 'panel', 'editorAndPanel'],
enum: ['never', 'editor', 'panel', 'editorAndPanel'],
default: 'editor'
},
[TerminalSettingId.EnableBell]: {