Skip to content

Commit

Permalink
new debug setting for clearing a terminal before reusing; fixes #116699
Browse files Browse the repository at this point in the history
  • Loading branch information
weinand committed Mar 16, 2021
1 parent 149a8b7 commit 21d2014
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/vs/workbench/api/node/extHostDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 => {
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/debug/browser/debug.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 21d2014

Please sign in to comment.