new debug setting for clearing a terminal before reusing; fixes #116699

This commit is contained in:
Andre Weinand 2021-03-16 13:09:26 +01:00
parent 149a8b71c5
commit 21d20148ee
2 changed files with 20 additions and 1 deletions

View file

@ -5,6 +5,7 @@
import * as nls from 'vs/nls';
import type * as vscode from 'vscode';
import * as platform from 'vs/base/common/platform';
import { DebugAdapterExecutable } from 'vs/workbench/api/common/extHostTypes';
import { ExecutableDebugAdapter, SocketDebugAdapter, NamedPipeDebugAdapter } from 'vs/workbench/contrib/debug/node/debugAdapter';
import { AbstractDebugAdapter } from 'vs/workbench/contrib/debug/common/abstractDebugAdapter';
@ -109,10 +110,23 @@ export class ExtHostDebugService extends ExtHostDebugServiceBase {
if (giveShellTimeToInitialize) {
// give a new terminal some time to initialize the shell
await new Promise(resolve => setTimeout(resolve, 1000));
} else {
if (configProvider.getConfiguration('debug.terminal').get<boolean>('clearBeforeReusing')) {
// clear terminal before reusing it
if (shell.indexOf('powershell') >= 0 || shell.indexOf('pwsh') >= 0 || shell.indexOf('cmd.exe') >= 0) {
terminal.sendText('cls');
} else if (shell.indexOf('bash') >= 0) {
terminal.sendText('clear');
} else if (platform.isWindows) {
terminal.sendText('cls');
} else {
terminal.sendText('clear');
}
}
}
const command = prepareCommand(shell, args.args, cwdForPrepareCommand, args.env);
terminal.sendText(command, true);
terminal.sendText(command);
// Mark terminal as unused when its session ends, see #112055
const sessionListener = this.onDidTerminateDebugSession(s => {

View file

@ -398,6 +398,11 @@ configurationRegistry.registerConfiguration({
description: nls.localize('debug.console.closeOnEnd', "Controls if the debug console should be automatically closed when the debug session ends."),
default: false
},
'debug.terminal.clearBeforeReusing': {
type: 'boolean',
description: nls.localize({ comment: ['This is the description for a setting'], key: 'debug.terminal.clearBeforeReusing' }, "Before starting a new debug session in an integrated or external terminal, clear the terminal."),
default: false
},
'debug.openDebug': {
enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart', 'openOnDebugBreak'],
default: 'openOnFirstSessionStart',