未验证 提交 e3f803d9 编写于 作者: A Alex Ross 提交者: GitHub

Add a new presentation option to clear the terminal before executing task (#61329)

Fixes #30058
上级 8e71de66
......@@ -4659,6 +4659,11 @@ declare module 'vscode' {
* Controls whether to show the "Terminal will be reused by tasks, press any key to close it" message.
*/
showReuseMessage?: boolean;
/**
* Controls whether the terminal is cleared before executing the task.
*/
clearBeforeExecuting?: boolean;
}
/**
......
......@@ -91,7 +91,7 @@ namespace TaskPresentationOptionsDTO {
}
export function to(value: TaskPresentationOptionsDTO): PresentationOptions {
if (value === void 0 || value === null) {
return { reveal: RevealKind.Always, echo: true, focus: false, panel: PanelKind.Shared, showReuseMessage: true };
return { reveal: RevealKind.Always, echo: true, focus: false, panel: PanelKind.Shared, showReuseMessage: true, clearBeforeExecuting: false };
}
return Objects.assign(Object.create(null), value);
}
......
......@@ -231,14 +231,15 @@ namespace TaskPanelKind {
namespace PresentationOptions {
export function from(value: vscode.TaskPresentationOptions): tasks.PresentationOptions {
if (value === void 0 || value === null) {
return { reveal: tasks.RevealKind.Always, echo: true, focus: false, panel: tasks.PanelKind.Shared, showReuseMessage: true };
return { reveal: tasks.RevealKind.Always, echo: true, focus: false, panel: tasks.PanelKind.Shared, showReuseMessage: true, clearBeforeExecuting: false };
}
return {
reveal: TaskRevealKind.from(value.reveal),
echo: value.echo === void 0 ? true : !!value.echo,
focus: !!value.focus,
panel: TaskPanelKind.from(value.panel),
showReuseMessage: value.showReuseMessage === void 0 ? true : !!value.showReuseMessage
showReuseMessage: value.showReuseMessage === void 0 ? true : !!value.showReuseMessage,
clearBeforeExecuting: value.clearBeforeExecuting === void 0 ? false : !!value.clearBeforeExecuting,
};
}
}
......
......@@ -16,6 +16,7 @@ export interface TaskPresentationOptionsDTO {
focus?: boolean;
panel?: number;
showReuseMessage?: boolean;
clearBeforeExecuting?: boolean;
}
export interface ExecutionOptionsDTO {
......
......@@ -203,6 +203,11 @@ export interface PresentationOptions {
* Controls whether to show the "Terminal will be reused by tasks, press any key to close it" message.
*/
showReuseMessage: boolean;
/**
* Controls whether to clear the terminal before executing the task.
*/
clearBeforeExecuting: boolean;
}
export enum RuntimeType {
......
......@@ -82,7 +82,8 @@ const presentation: IJSONSchema = {
reveal: 'always',
focus: false,
panel: 'shared',
showReuseMessage: true
showReuseMessage: true,
clearBeforeExecuting: false,
},
description: nls.localize('JsonSchema.tasks.presentation', 'Configures the panel that is used to present the task\'s ouput and reads its input.'),
additionalProperties: false,
......@@ -118,6 +119,11 @@ const presentation: IJSONSchema = {
type: 'boolean',
default: true,
description: nls.localize('JsonSchema.tasks.presentation.showReuseMessage', 'Controls whether to show the `Terminal will be reused by tasks, press any key to close it` message.')
},
clearBeforeExecuting: {
type: 'boolean',
default: false,
description: nls.localize('JsonSchema.tasks.presentation.clearBeforeExecuting', 'Controls whether the terminal is cleared before executing the task.')
}
}
};
......
......@@ -683,6 +683,9 @@ export class TerminalTaskSystem implements ITaskSystem {
}
if (terminalToReuse) {
terminalToReuse.terminal.reuseTerminal(shellLaunchConfig);
if (task.command.presentation.clearBeforeExecuting) {
terminalToReuse.terminal.clear();
}
return [terminalToReuse.terminal, commandExecutable, undefined];
}
......
......@@ -112,6 +112,11 @@ export interface PresentationOptions {
* Controls whether to show the "Terminal will be reused by tasks, press any key to close it" message.
*/
showReuseMessage?: boolean;
/**
* Controls whether the terminal should be cleared before running the task.
*/
clearBeforeExecuting?: boolean;
}
export interface TaskIdentifier {
......@@ -754,6 +759,7 @@ namespace CommandConfiguration {
let focus: boolean;
let panel: Tasks.PanelKind;
let showReuseMessage: boolean;
let clearBeforeExecuting: boolean;
if (Types.isBoolean(config.echoCommand)) {
echo = config.echoCommand;
}
......@@ -777,11 +783,14 @@ namespace CommandConfiguration {
if (Types.isBoolean(presentation.showReuseMessage)) {
showReuseMessage = presentation.showReuseMessage;
}
if (Types.isBoolean(presentation.clearBeforeExecuting)) {
clearBeforeExecuting = presentation.clearBeforeExecuting;
}
}
if (echo === void 0 && reveal === void 0 && focus === void 0 && panel === void 0 && showReuseMessage === void 0) {
return undefined;
}
return { echo, reveal, focus, panel, showReuseMessage };
return { echo, reveal, focus, panel, showReuseMessage, clearBeforeExecuting };
}
export function assignProperties(target: Tasks.PresentationOptions, source: Tasks.PresentationOptions): Tasks.PresentationOptions {
......@@ -794,7 +803,7 @@ namespace CommandConfiguration {
export function fillDefaults(value: Tasks.PresentationOptions, context: ParseContext): Tasks.PresentationOptions {
let defaultEcho = context.engine === Tasks.ExecutionEngine.Terminal ? true : false;
return _fillDefaults(value, { echo: defaultEcho, reveal: Tasks.RevealKind.Always, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true }, properties, context);
return _fillDefaults(value, { echo: defaultEcho, reveal: Tasks.RevealKind.Always, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true, clearBeforeExecuting: false }, properties, context);
}
export function freeze(value: Tasks.PresentationOptions): Readonly<Tasks.PresentationOptions> {
......
......@@ -83,7 +83,7 @@ class PresentationBuilder {
public result: Tasks.PresentationOptions;
constructor(public parent: CommandConfigurationBuilder) {
this.result = { echo: false, reveal: Tasks.RevealKind.Always, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true };
this.result = { echo: false, reveal: Tasks.RevealKind.Always, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true, clearBeforeExecuting: false };
}
public echo(value: boolean): PresentationBuilder {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册