From 3d8cb93c35782bc33fdce4dc6b1a7a583149ebe4 Mon Sep 17 00:00:00 2001 From: Sebastian Witthus Date: Sat, 23 Mar 2019 20:05:14 +0100 Subject: [PATCH 1/9] Add 'revealProblem' option. --- .../contrib/tasks/common/jsonSchema_v2.ts | 11 +++++ .../contrib/tasks/common/problemCollectors.ts | 4 +- .../contrib/tasks/common/taskConfiguration.ts | 16 +++++-- .../workbench/contrib/tasks/common/tasks.ts | 43 ++++++++++++++++++- .../electron-browser/task.contribution.ts | 3 +- .../electron-browser/terminalTaskSystem.ts | 14 +++++- .../electron-browser/configuration.test.ts | 2 +- 7 files changed, 84 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts index 4c93a6cab287b..52da1c82ece83 100644 --- a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts +++ b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts @@ -100,6 +100,17 @@ const presentation: IJSONSchema = { default: false, description: nls.localize('JsonSchema.tasks.presentation.focus', 'Controls whether the panel takes focus. Default is false. If set to true the panel is revealed as well.') }, + revealProblem: { + type: 'string', + enum: ['always', 'onProblemFound', 'never'], + enumDescriptions: [ + nls.localize('JsonSchema.tasks.presentation.revealProblem.always', 'Always reveals the problems pane when this task is executed.'), + nls.localize('JsonSchema.tasks.presentation.revealProblem.onProblemFound', 'Only reveals the problems pane if a problem is found.'), + nls.localize('JsonSchema.tasks.presentation.revealProblem.never', 'Never reveals the problems pane when this task is executed.'), + ], + default: 'never', + description: nls.localize('JsonSchema.tasks.presentation.revealProblem', 'Controls whether the problems pane is revealed when running this task or not. Default is \"never\".') + }, reveal: { type: 'string', enum: ['always', 'silent', 'never'], diff --git a/src/vs/workbench/contrib/tasks/common/problemCollectors.ts b/src/vs/workbench/contrib/tasks/common/problemCollectors.ts index 1e576997a740c..ef9b7224350a1 100644 --- a/src/vs/workbench/contrib/tasks/common/problemCollectors.ts +++ b/src/vs/workbench/contrib/tasks/common/problemCollectors.ts @@ -16,7 +16,8 @@ import { generateUuid } from 'vs/base/common/uuid'; export const enum ProblemCollectorEventKind { BackgroundProcessingBegins = 'backgroundProcessingBegins', - BackgroundProcessingEnds = 'backgroundProcessingEnds' + BackgroundProcessingEnds = 'backgroundProcessingEnds', + ProblemFound = 'problemFound' } export interface ProblemCollectorEvent { @@ -280,6 +281,7 @@ export class AbstractProblemCollector implements IDisposable { } protected deliverMarkersPerOwnerAndResource(owner: string, resource: string): void { + this._onDidStateChange.fire(ProblemCollectorEvent.create(ProblemCollectorEventKind.ProblemFound)); let markersPerOwner = this.markers.get(owner); if (!markersPerOwner) { return; diff --git a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts index dad7b3896f50e..7f8ff5ed993c3 100644 --- a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts +++ b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts @@ -91,6 +91,12 @@ export interface PresentationOptionsConfig { */ reveal?: string; + /** + * Controls whether the problems pane is revealed when running this task or not. + * Defaults to `RevealKind.Never`. + */ + revealProblem?: string; + /** * Controls whether the executed command is printed to the output window or terminal as well. */ @@ -796,7 +802,7 @@ namespace CommandOptions { namespace CommandConfiguration { export namespace PresentationOptions { - const properties: MetaData[] = [{ property: 'echo' }, { property: 'reveal' }, { property: 'focus' }, { property: 'panel' }, { property: 'showReuseMessage' }, { property: 'clear' }, { property: 'group' }]; + const properties: MetaData[] = [{ property: 'echo' }, { property: 'reveal' }, { property: 'revealProblem' }, { property: 'focus' }, { property: 'panel' }, { property: 'showReuseMessage' }, { property: 'clear' }, { property: 'group' }]; interface PresentationOptionsShape extends LegacyCommandProperties { presentation?: PresentationOptionsConfig; @@ -805,6 +811,7 @@ namespace CommandConfiguration { export function from(this: void, config: PresentationOptionsShape, context: ParseContext): Tasks.PresentationOptions | undefined { let echo: boolean; let reveal: Tasks.RevealKind; + let revealProblem: Tasks.RevealProblemKind; let focus: boolean; let panel: Tasks.PanelKind; let showReuseMessage: boolean; @@ -827,6 +834,9 @@ namespace CommandConfiguration { if (Types.isString(presentation.reveal)) { reveal = Tasks.RevealKind.fromString(presentation.reveal); } + if (Types.isString(presentation.revealProblem)) { + revealProblem = Tasks.RevealProblemKind.fromString(presentation.revealProblem); + } if (Types.isBoolean(presentation.focus)) { focus = presentation.focus; } @@ -847,7 +857,7 @@ namespace CommandConfiguration { if (!hasProps) { return undefined; } - return { echo: echo!, reveal: reveal!, focus: focus!, panel: panel!, showReuseMessage: showReuseMessage!, clear: clear!, group }; + return { echo: echo!, reveal: reveal!, revealProblem: revealProblem!, focus: focus!, panel: panel!, showReuseMessage: showReuseMessage!, clear: clear!, group }; } export function assignProperties(target: Tasks.PresentationOptions, source: Tasks.PresentationOptions | undefined): Tasks.PresentationOptions | undefined { @@ -860,7 +870,7 @@ namespace CommandConfiguration { export function fillDefaults(value: Tasks.PresentationOptions, context: ParseContext): Tasks.PresentationOptions | undefined { 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, clear: false }, properties, context); + return _fillDefaults(value, { echo: defaultEcho, reveal: Tasks.RevealKind.Always, revealProblem: Tasks.RevealProblemKind.Never, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true, clear: false }, properties, context); } export function freeze(value: Tasks.PresentationOptions): Readonly | undefined { diff --git a/src/vs/workbench/contrib/tasks/common/tasks.ts b/src/vs/workbench/contrib/tasks/common/tasks.ts index 64b814c9714d5..86b2966eca640 100644 --- a/src/vs/workbench/contrib/tasks/common/tasks.ts +++ b/src/vs/workbench/contrib/tasks/common/tasks.ts @@ -12,8 +12,8 @@ import { UriComponents } from 'vs/base/common/uri'; import { ProblemMatcher } from 'vs/workbench/contrib/tasks/common/problemMatcher'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { RawContextKey } from 'vs/platform/contextkey/common/contextkey'; -import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; import { TaskDefinitionRegistry } from 'vs/workbench/contrib/tasks/common/taskDefinitionRegistry'; +import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; export const TASK_RUNNING_STATE = new RawContextKey('taskRunning', false); @@ -148,6 +148,39 @@ export namespace RevealKind { } } +export enum RevealProblemKind { + /** + * Never reveals the problems pane when this task is executed. + */ + Never = 1, + + + /** + * Only reveals the problems pane if a problem is found. + */ + OnProblemFound = 2, + + /** + * Never reveals the problems pane when this task is executed. + */ + Always = 3 +} + +export namespace RevealProblemKind { + export function fromString(this: void, value: string): RevealProblemKind { + switch (value.toLowerCase()) { + case 'never': + return RevealProblemKind.Never; + case 'onproblemfound': + return RevealProblemKind.OnProblemFound; + case 'always': + return RevealProblemKind.Always; + default: + return RevealProblemKind.Always; + } + } +} + export enum PanelKind { /** @@ -189,6 +222,12 @@ export interface PresentationOptions { */ reveal: RevealKind; + /** + * Controls whether the problems pane is revealed when running this task or not. + * Defaults to `RevealProblemKind.Never`. + */ + revealProblem: RevealProblemKind; + /** * Controls whether the command associated with the task is echoed * in the user interface. @@ -225,7 +264,7 @@ export interface PresentationOptions { export namespace PresentationOptions { export const defaults: PresentationOptions = { - echo: true, reveal: RevealKind.Always, focus: false, panel: PanelKind.Shared, showReuseMessage: true, clear: false + echo: true, reveal: RevealKind.Always, revealProblem: RevealProblemKind.Never, focus: false, panel: PanelKind.Shared, showReuseMessage: true, clear: false }; } diff --git a/src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts index 1d3b93e0bb6c8..c14929dbc7cef 100644 --- a/src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/contrib/tasks/electron-browser/task.contribution.ts @@ -467,6 +467,7 @@ class TaskService extends Disposable implements ITaskService { @IConfigurationService private readonly configurationService: IConfigurationService, @IMarkerService private readonly markerService: IMarkerService, @IOutputService private readonly outputService: IOutputService, + @IPanelService private readonly panelService: IPanelService, @IEditorService private readonly editorService: IEditorService, @IFileService private readonly fileService: IFileService, @IWorkspaceContextService private readonly contextService: IWorkspaceContextService, @@ -1345,7 +1346,7 @@ class TaskService extends Disposable implements ITaskService { } if (this.executionEngine === ExecutionEngine.Terminal) { this._taskSystem = new TerminalTaskSystem( - this.terminalService, this.outputService, this.markerService, + this.terminalService, this.outputService, this.panelService, this.markerService, this.modelService, this.configurationResolverService, this.telemetryService, this.contextService, this._windowService, TaskService.OutputChannelId, diff --git a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts index aec9d33245d7a..2be278864e000 100644 --- a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts @@ -22,6 +22,7 @@ import { IMarkerService, MarkerSeverity } from 'vs/platform/markers/common/marke import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { IModelService } from 'vs/editor/common/services/modelService'; import { ProblemMatcher, ProblemMatcherRegistry /*, ProblemPattern, getResource */ } from 'vs/workbench/contrib/tasks/common/problemMatcher'; +import Constants from 'vs/workbench/contrib/markers/browser/constants'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; @@ -31,7 +32,7 @@ import { IOutputService } from 'vs/workbench/contrib/output/common/output'; import { StartStopProblemCollector, WatchingProblemCollector, ProblemCollectorEventKind } from 'vs/workbench/contrib/tasks/common/problemCollectors'; import { Task, CustomTask, ContributedTask, RevealKind, CommandOptions, ShellConfiguration, RuntimeType, PanelKind, - TaskEvent, TaskEventKind, ShellQuotingOptions, ShellQuoting, CommandString, CommandConfiguration, ExtensionTaskSource, TaskScope + TaskEvent, TaskEventKind, ShellQuotingOptions, ShellQuoting, CommandString, CommandConfiguration, ExtensionTaskSource, TaskScope, RevealProblemKind } from 'vs/workbench/contrib/tasks/common/tasks'; import { ITaskSystem, ITaskSummary, ITaskExecuteResult, TaskExecuteKind, TaskError, TaskErrors, ITaskResolver, @@ -42,6 +43,7 @@ import { URI } from 'vs/base/common/uri'; import { IWindowService } from 'vs/platform/windows/common/windows'; import { Schemas } from 'vs/base/common/network'; import { getWindowsBuildNumber } from 'vs/workbench/contrib/terminal/node/terminal'; +import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; interface TerminalData { terminal: ITerminalInstance; @@ -160,6 +162,7 @@ export class TerminalTaskSystem implements ITaskSystem { private readonly _onDidStateChange: Emitter; constructor(private terminalService: ITerminalService, private outputService: IOutputService, + private panelService: IPanelService, private markerService: IMarkerService, private modelService: IModelService, private configurationResolverService: IConfigurationResolverService, private telemetryService: ITelemetryService, @@ -521,6 +524,8 @@ export class TerminalTaskSystem implements ITaskSystem { this.terminalService.showPanel(false); } } + } else if (event.kind === ProblemCollectorEventKind.ProblemFound) { + this.panelService.openPanel(Constants.MARKERS_PANEL_ID, true); } })); watchingProblemMatcher.aboutToStart(); @@ -647,6 +652,10 @@ export class TerminalTaskSystem implements ITaskSystem { this.terminalService.setActiveInstance(terminal); this.terminalService.showPanel(false); } + let revealProblem = task.command.presentation!.revealProblem; + if (terminal && (revealProblem === RevealProblemKind.OnProblemFound) && (startStopProblemMatcher.numberOfMatches > 0)) { + this.panelService.openPanel(Constants.MARKERS_PANEL_ID); + } startStopProblemMatcher.done(); startStopProblemMatcher.dispose(); registeredLinkMatchers.forEach(handle => { @@ -673,6 +682,9 @@ export class TerminalTaskSystem implements ITaskSystem { if (!terminal) { return Promise.reject(new Error(`Failed to create terminal for task ${task._label}`)); } + if (task.command.presentation && (task.command.presentation.revealProblem === RevealProblemKind.Always)) { + this.panelService.openPanel(Constants.MARKERS_PANEL_ID); + } if (task.command.presentation && (task.command.presentation.reveal === RevealKind.Always)) { this.terminalService.setActiveInstance(terminal); this.terminalService.showPanel(task.command.presentation.focus); diff --git a/src/vs/workbench/contrib/tasks/test/electron-browser/configuration.test.ts b/src/vs/workbench/contrib/tasks/test/electron-browser/configuration.test.ts index de2442738e2ce..191adbb0ee489 100644 --- a/src/vs/workbench/contrib/tasks/test/electron-browser/configuration.test.ts +++ b/src/vs/workbench/contrib/tasks/test/electron-browser/configuration.test.ts @@ -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, clear: false }; + this.result = { echo: false, reveal: Tasks.RevealKind.Always, revealProblem: Tasks.RevealProblemKind.Never, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true, clear: false }; } public echo(value: boolean): PresentationBuilder { From 8079c1d3c598ca1987c716f7f5f79304ee1f2755 Mon Sep 17 00:00:00 2001 From: Sebastian Witthus Date: Thu, 28 Mar 2019 12:50:28 +0100 Subject: [PATCH 2/9] Fix typo: problem pane -> panel. --- src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts | 8 ++++---- .../workbench/contrib/tasks/common/taskConfiguration.ts | 2 +- src/vs/workbench/contrib/tasks/common/tasks.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts index 52da1c82ece83..6d02b18cfe469 100644 --- a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts +++ b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts @@ -104,12 +104,12 @@ const presentation: IJSONSchema = { type: 'string', enum: ['always', 'onProblemFound', 'never'], enumDescriptions: [ - nls.localize('JsonSchema.tasks.presentation.revealProblem.always', 'Always reveals the problems pane when this task is executed.'), - nls.localize('JsonSchema.tasks.presentation.revealProblem.onProblemFound', 'Only reveals the problems pane if a problem is found.'), - nls.localize('JsonSchema.tasks.presentation.revealProblem.never', 'Never reveals the problems pane when this task is executed.'), + nls.localize('JsonSchema.tasks.presentation.revealProblem.always', 'Always reveals the problems panel when this task is executed.'), + nls.localize('JsonSchema.tasks.presentation.revealProblem.onProblemFound', 'Only reveals the problems panel if a problem is found.'), + nls.localize('JsonSchema.tasks.presentation.revealProblem.never', 'Never reveals the problems panel when this task is executed.'), ], default: 'never', - description: nls.localize('JsonSchema.tasks.presentation.revealProblem', 'Controls whether the problems pane is revealed when running this task or not. Default is \"never\".') + description: nls.localize('JsonSchema.tasks.presentation.revealProblem', 'Controls whether the problems panel is revealed when running this task or not. Default is \"never\".') }, reveal: { type: 'string', diff --git a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts index 7f8ff5ed993c3..1ec4c8b5541e7 100644 --- a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts +++ b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts @@ -92,7 +92,7 @@ export interface PresentationOptionsConfig { reveal?: string; /** - * Controls whether the problems pane is revealed when running this task or not. + * Controls whether the problems panel is revealed when running this task or not. * Defaults to `RevealKind.Never`. */ revealProblem?: string; diff --git a/src/vs/workbench/contrib/tasks/common/tasks.ts b/src/vs/workbench/contrib/tasks/common/tasks.ts index e254a5aa1ad7c..5b841aeed9a87 100644 --- a/src/vs/workbench/contrib/tasks/common/tasks.ts +++ b/src/vs/workbench/contrib/tasks/common/tasks.ts @@ -150,18 +150,18 @@ export namespace RevealKind { export enum RevealProblemKind { /** - * Never reveals the problems pane when this task is executed. + * Never reveals the problems panel when this task is executed. */ Never = 1, /** - * Only reveals the problems pane if a problem is found. + * Only reveals the problems panel if a problem is found. */ OnProblemFound = 2, /** - * Never reveals the problems pane when this task is executed. + * Never reveals the problems panel when this task is executed. */ Always = 3 } From 8648eb6d21b8a19a1a81f09326db05cf5649709c Mon Sep 17 00:00:00 2001 From: Sebastian Witthus Date: Thu, 28 Mar 2019 12:52:09 +0100 Subject: [PATCH 3/9] Rename: OnProblemFound -> OnProblem --- src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts | 4 ++-- src/vs/workbench/contrib/tasks/common/tasks.ts | 6 +++--- .../contrib/tasks/electron-browser/terminalTaskSystem.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts index 6d02b18cfe469..a305d786f85fa 100644 --- a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts +++ b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts @@ -102,10 +102,10 @@ const presentation: IJSONSchema = { }, revealProblem: { type: 'string', - enum: ['always', 'onProblemFound', 'never'], + enum: ['always', 'onProblem', 'never'], enumDescriptions: [ nls.localize('JsonSchema.tasks.presentation.revealProblem.always', 'Always reveals the problems panel when this task is executed.'), - nls.localize('JsonSchema.tasks.presentation.revealProblem.onProblemFound', 'Only reveals the problems panel if a problem is found.'), + nls.localize('JsonSchema.tasks.presentation.revealProblem.onProblem', 'Only reveals the problems panel if a problem is found.'), nls.localize('JsonSchema.tasks.presentation.revealProblem.never', 'Never reveals the problems panel when this task is executed.'), ], default: 'never', diff --git a/src/vs/workbench/contrib/tasks/common/tasks.ts b/src/vs/workbench/contrib/tasks/common/tasks.ts index 5b841aeed9a87..459bc35ff2a11 100644 --- a/src/vs/workbench/contrib/tasks/common/tasks.ts +++ b/src/vs/workbench/contrib/tasks/common/tasks.ts @@ -158,7 +158,7 @@ export enum RevealProblemKind { /** * Only reveals the problems panel if a problem is found. */ - OnProblemFound = 2, + OnProblem = 2, /** * Never reveals the problems panel when this task is executed. @@ -171,8 +171,8 @@ export namespace RevealProblemKind { switch (value.toLowerCase()) { case 'never': return RevealProblemKind.Never; - case 'onproblemfound': - return RevealProblemKind.OnProblemFound; + case 'onproblem': + return RevealProblemKind.OnProblem; case 'always': return RevealProblemKind.Always; default: diff --git a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts index 27a74f1c3d9d3..2767ecbf1d0c2 100644 --- a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts @@ -653,7 +653,7 @@ export class TerminalTaskSystem implements ITaskSystem { this.terminalService.showPanel(false); } let revealProblem = task.command.presentation!.revealProblem; - if (terminal && (revealProblem === RevealProblemKind.OnProblemFound) && (startStopProblemMatcher.numberOfMatches > 0)) { + if (terminal && (revealProblem === RevealProblemKind.OnProblem) && (startStopProblemMatcher.numberOfMatches > 0)) { this.panelService.openPanel(Constants.MARKERS_PANEL_ID); } startStopProblemMatcher.done(); From f05eafab956ed812ee01cb0268ec5c3717f1b708 Mon Sep 17 00:00:00 2001 From: Sebastian Witthus Date: Thu, 28 Mar 2019 12:56:55 +0100 Subject: [PATCH 4/9] Add comments to jsonSchema regariding precedence revealProblem > reveal. --- src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts index a305d786f85fa..c22686b053700 100644 --- a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts +++ b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts @@ -109,7 +109,7 @@ const presentation: IJSONSchema = { nls.localize('JsonSchema.tasks.presentation.revealProblem.never', 'Never reveals the problems panel when this task is executed.'), ], default: 'never', - description: nls.localize('JsonSchema.tasks.presentation.revealProblem', 'Controls whether the problems panel is revealed when running this task or not. Default is \"never\".') + description: nls.localize('JsonSchema.tasks.presentation.revealProblem', 'Controls whether the problems panel is revealed when running this task or not. Takes precedence over option \"reveal\". Default is \"never\".') }, reveal: { type: 'string', @@ -120,7 +120,7 @@ const presentation: IJSONSchema = { nls.localize('JsonSchema.tasks.presentation.reveal.never', 'Never reveals the terminal when this task is executed.'), ], default: 'always', - description: nls.localize('JsonSchema.tasks.presentation.reveals', 'Controls whether the panel running the task is revealed or not. Default is \"always\".') + description: nls.localize('JsonSchema.tasks.presentation.reveals', 'Controls whether the panel running the task is revealed or not. May be overridden by option \"revealProblem\". Default is \"always\".') }, panel: { type: 'string', From b330f3433da90f612680d90ee8c3dec0810cba01 Mon Sep 17 00:00:00 2001 From: Sebastian Witthus Date: Thu, 28 Mar 2019 13:01:58 +0100 Subject: [PATCH 5/9] Change default setting for revealProblem. --- src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts | 2 +- .../contrib/tasks/common/taskConfiguration.ts | 2 +- src/vs/workbench/contrib/tasks/common/tasks.ts | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts index c22686b053700..cc918072a1ce9 100644 --- a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts +++ b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts @@ -109,7 +109,7 @@ const presentation: IJSONSchema = { nls.localize('JsonSchema.tasks.presentation.revealProblem.never', 'Never reveals the problems panel when this task is executed.'), ], default: 'never', - description: nls.localize('JsonSchema.tasks.presentation.revealProblem', 'Controls whether the problems panel is revealed when running this task or not. Takes precedence over option \"reveal\". Default is \"never\".') + description: nls.localize('JsonSchema.tasks.presentation.revealProblem', 'Controls whether the problems panel is revealed when running this task or not. Takes precedence over option \"reveal\". Default is \"onProblem\".') }, reveal: { type: 'string', diff --git a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts index 1ec4c8b5541e7..de05e5d2b854a 100644 --- a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts +++ b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts @@ -870,7 +870,7 @@ namespace CommandConfiguration { export function fillDefaults(value: Tasks.PresentationOptions, context: ParseContext): Tasks.PresentationOptions | undefined { let defaultEcho = context.engine === Tasks.ExecutionEngine.Terminal ? true : false; - return _fillDefaults(value, { echo: defaultEcho, reveal: Tasks.RevealKind.Always, revealProblem: Tasks.RevealProblemKind.Never, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true, clear: false }, properties, context); + return _fillDefaults(value, { echo: defaultEcho, reveal: Tasks.RevealKind.Always, revealProblem: Tasks.RevealProblemKind.OnProblem, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true, clear: false }, properties, context); } export function freeze(value: Tasks.PresentationOptions): Readonly | undefined { diff --git a/src/vs/workbench/contrib/tasks/common/tasks.ts b/src/vs/workbench/contrib/tasks/common/tasks.ts index 459bc35ff2a11..7661e19279bc8 100644 --- a/src/vs/workbench/contrib/tasks/common/tasks.ts +++ b/src/vs/workbench/contrib/tasks/common/tasks.ts @@ -169,14 +169,14 @@ export enum RevealProblemKind { export namespace RevealProblemKind { export function fromString(this: void, value: string): RevealProblemKind { switch (value.toLowerCase()) { + case 'always': + return RevealProblemKind.Always; case 'never': return RevealProblemKind.Never; case 'onproblem': return RevealProblemKind.OnProblem; - case 'always': - return RevealProblemKind.Always; default: - return RevealProblemKind.Always; + return RevealProblemKind.OnProblem; } } } @@ -224,7 +224,7 @@ export interface PresentationOptions { /** * Controls whether the problems pane is revealed when running this task or not. - * Defaults to `RevealProblemKind.Never`. + * Defaults to `RevealProblemKind.OnProblem`. */ revealProblem: RevealProblemKind; @@ -264,7 +264,7 @@ export interface PresentationOptions { export namespace PresentationOptions { export const defaults: PresentationOptions = { - echo: true, reveal: RevealKind.Always, revealProblem: RevealProblemKind.Never, focus: false, panel: PanelKind.Shared, showReuseMessage: true, clear: false + echo: true, reveal: RevealKind.Always, revealProblem: RevealProblemKind.OnProblem, focus: false, panel: PanelKind.Shared, showReuseMessage: true, clear: false }; } From f1e4348084fbc3191ed2c2faaec9d3ecfb74d785 Mon Sep 17 00:00:00 2001 From: Sebastian Witthus Date: Thu, 28 Mar 2019 13:38:52 +0100 Subject: [PATCH 6/9] Only open problem panel once processing ends. --- .../contrib/tasks/common/problemCollectors.ts | 4 +-- .../electron-browser/terminalTaskSystem.ts | 31 +++++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/common/problemCollectors.ts b/src/vs/workbench/contrib/tasks/common/problemCollectors.ts index ef9b7224350a1..1e576997a740c 100644 --- a/src/vs/workbench/contrib/tasks/common/problemCollectors.ts +++ b/src/vs/workbench/contrib/tasks/common/problemCollectors.ts @@ -16,8 +16,7 @@ import { generateUuid } from 'vs/base/common/uuid'; export const enum ProblemCollectorEventKind { BackgroundProcessingBegins = 'backgroundProcessingBegins', - BackgroundProcessingEnds = 'backgroundProcessingEnds', - ProblemFound = 'problemFound' + BackgroundProcessingEnds = 'backgroundProcessingEnds' } export interface ProblemCollectorEvent { @@ -281,7 +280,6 @@ export class AbstractProblemCollector implements IDisposable { } protected deliverMarkersPerOwnerAndResource(owner: string, resource: string): void { - this._onDidStateChange.fire(ProblemCollectorEvent.create(ProblemCollectorEventKind.ProblemFound)); let markersPerOwner = this.markers.get(owner); if (!markersPerOwner) { return; diff --git a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts index 2767ecbf1d0c2..573b8b9e37442 100644 --- a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts @@ -517,15 +517,18 @@ export class TerminalTaskSystem implements ITaskSystem { eventCounter--; this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.Inactive, task)); if (eventCounter === 0) { - let reveal = task.command.presentation!.reveal; - if ((reveal === RevealKind.Silent) && (watchingProblemMatcher.numberOfMatches > 0) && watchingProblemMatcher.maxMarkerSeverity && + if ((watchingProblemMatcher.numberOfMatches > 0) && watchingProblemMatcher.maxMarkerSeverity && (watchingProblemMatcher.maxMarkerSeverity >= MarkerSeverity.Error)) { - this.terminalService.setActiveInstance(terminal!); - this.terminalService.showPanel(false); + let reveal = task.command.presentation!.reveal; + let revealProblem = task.command.presentation!.revealProblem; + if (revealProblem === RevealProblemKind.OnProblem) { + this.panelService.openPanel(Constants.MARKERS_PANEL_ID, true); + } else if (reveal === RevealKind.Silent) { + this.terminalService.setActiveInstance(terminal!); + this.terminalService.showPanel(false); + } } } - } else if (event.kind === ProblemCollectorEventKind.ProblemFound) { - this.panelService.openPanel(Constants.MARKERS_PANEL_ID, true); } })); watchingProblemMatcher.aboutToStart(); @@ -647,15 +650,16 @@ export class TerminalTaskSystem implements ITaskSystem { } } let reveal = task.command.presentation!.reveal; - if (terminal && (reveal === RevealKind.Silent) && ((exitCode !== 0) || (startStopProblemMatcher.numberOfMatches > 0) && startStopProblemMatcher.maxMarkerSeverity && + let revealProblem = task.command.presentation!.revealProblem; + let revealProblemPanel = terminal && (revealProblem === RevealProblemKind.OnProblem) && (startStopProblemMatcher.numberOfMatches > 0); + if (revealProblemPanel) { + this.panelService.openPanel(Constants.MARKERS_PANEL_ID); + } + if (terminal && !revealProblemPanel && (reveal === RevealKind.Silent) && ((exitCode !== 0) || (startStopProblemMatcher.numberOfMatches > 0) && startStopProblemMatcher.maxMarkerSeverity && (startStopProblemMatcher.maxMarkerSeverity >= MarkerSeverity.Error))) { this.terminalService.setActiveInstance(terminal); this.terminalService.showPanel(false); } - let revealProblem = task.command.presentation!.revealProblem; - if (terminal && (revealProblem === RevealProblemKind.OnProblem) && (startStopProblemMatcher.numberOfMatches > 0)) { - this.panelService.openPanel(Constants.MARKERS_PANEL_ID); - } startStopProblemMatcher.done(); startStopProblemMatcher.dispose(); registeredLinkMatchers.forEach(handle => { @@ -682,10 +686,11 @@ export class TerminalTaskSystem implements ITaskSystem { if (!terminal) { return Promise.reject(new Error(`Failed to create terminal for task ${task._label}`)); } - if (task.command.presentation && (task.command.presentation.revealProblem === RevealProblemKind.Always)) { + let showProblemPanel = task.command.presentation && (task.command.presentation.revealProblem === RevealProblemKind.Always); + if (showProblemPanel) { this.panelService.openPanel(Constants.MARKERS_PANEL_ID); } - if (task.command.presentation && (task.command.presentation.reveal === RevealKind.Always)) { + if (task.command.presentation && !showProblemPanel && (task.command.presentation.reveal === RevealKind.Always)) { this.terminalService.setActiveInstance(terminal); this.terminalService.showPanel(task.command.presentation.focus); } From 1b8c429eb1e7f044c4a5d18f2de4e28a14ab766c Mon Sep 17 00:00:00 2001 From: Sebastian Witthus Date: Thu, 28 Mar 2019 14:57:49 +0100 Subject: [PATCH 7/9] Improve hints for 'reveal / silent'. --- src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts | 2 +- src/vs/workbench/contrib/tasks/common/tasks.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts index cc918072a1ce9..7f37c30867908 100644 --- a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts +++ b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts @@ -116,7 +116,7 @@ const presentation: IJSONSchema = { enum: ['always', 'silent', 'never'], enumDescriptions: [ nls.localize('JsonSchema.tasks.presentation.reveal.always', 'Always reveals the terminal when this task is executed.'), - nls.localize('JsonSchema.tasks.presentation.reveal.silent', 'Only reveals the terminal if the task exits with an error.'), + nls.localize('JsonSchema.tasks.presentation.reveal.silent', 'Only reveals the terminal if the task exits with an error or the problem matcher finds an error.'), nls.localize('JsonSchema.tasks.presentation.reveal.never', 'Never reveals the terminal when this task is executed.'), ], default: 'always', diff --git a/src/vs/workbench/contrib/tasks/common/tasks.ts b/src/vs/workbench/contrib/tasks/common/tasks.ts index 7661e19279bc8..06cda87b2a9d4 100644 --- a/src/vs/workbench/contrib/tasks/common/tasks.ts +++ b/src/vs/workbench/contrib/tasks/common/tasks.ts @@ -123,7 +123,9 @@ export enum RevealKind { /** * Only brings the terminal to front if a problem is detected executing the task - * (e.g. the task couldn't be started because). + * e.g. the task couldn't be started, + * the task ended with an exit code other than zero, + * or the problem matcher finding an error. */ Silent = 2, From 32c856dfd68a919915988ba6c28052860964968f Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Mon, 8 Apr 2019 11:49:49 +0200 Subject: [PATCH 8/9] Change default revealProblem to Never and update a few strings --- src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts | 2 +- src/vs/workbench/contrib/tasks/common/taskConfiguration.ts | 2 +- src/vs/workbench/contrib/tasks/common/tasks.ts | 6 +++--- .../contrib/tasks/electron-browser/terminalTaskSystem.ts | 6 ++---- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts index 7f37c30867908..75c271d9a428b 100644 --- a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts +++ b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts @@ -109,7 +109,7 @@ const presentation: IJSONSchema = { nls.localize('JsonSchema.tasks.presentation.revealProblem.never', 'Never reveals the problems panel when this task is executed.'), ], default: 'never', - description: nls.localize('JsonSchema.tasks.presentation.revealProblem', 'Controls whether the problems panel is revealed when running this task or not. Takes precedence over option \"reveal\". Default is \"onProblem\".') + description: nls.localize('JsonSchema.tasks.presentation.revealProblem', 'Controls whether the problems panel is revealed when running this task or not. Takes precedence over option \"reveal\". Default is \"never\".') }, reveal: { type: 'string', diff --git a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts index de05e5d2b854a..1ec4c8b5541e7 100644 --- a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts +++ b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts @@ -870,7 +870,7 @@ namespace CommandConfiguration { export function fillDefaults(value: Tasks.PresentationOptions, context: ParseContext): Tasks.PresentationOptions | undefined { let defaultEcho = context.engine === Tasks.ExecutionEngine.Terminal ? true : false; - return _fillDefaults(value, { echo: defaultEcho, reveal: Tasks.RevealKind.Always, revealProblem: Tasks.RevealProblemKind.OnProblem, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true, clear: false }, properties, context); + return _fillDefaults(value, { echo: defaultEcho, reveal: Tasks.RevealKind.Always, revealProblem: Tasks.RevealProblemKind.Never, focus: false, panel: Tasks.PanelKind.Shared, showReuseMessage: true, clear: false }, properties, context); } export function freeze(value: Tasks.PresentationOptions): Readonly | undefined { diff --git a/src/vs/workbench/contrib/tasks/common/tasks.ts b/src/vs/workbench/contrib/tasks/common/tasks.ts index 06cda87b2a9d4..c1f97913eb9ca 100644 --- a/src/vs/workbench/contrib/tasks/common/tasks.ts +++ b/src/vs/workbench/contrib/tasks/common/tasks.ts @@ -125,7 +125,7 @@ export enum RevealKind { * Only brings the terminal to front if a problem is detected executing the task * e.g. the task couldn't be started, * the task ended with an exit code other than zero, - * or the problem matcher finding an error. + * or the problem matcher found an error. */ Silent = 2, @@ -226,7 +226,7 @@ export interface PresentationOptions { /** * Controls whether the problems pane is revealed when running this task or not. - * Defaults to `RevealProblemKind.OnProblem`. + * Defaults to `RevealProblemKind.Never`. */ revealProblem: RevealProblemKind; @@ -266,7 +266,7 @@ export interface PresentationOptions { export namespace PresentationOptions { export const defaults: PresentationOptions = { - echo: true, reveal: RevealKind.Always, revealProblem: RevealProblemKind.OnProblem, focus: false, panel: PanelKind.Shared, showReuseMessage: true, clear: false + echo: true, reveal: RevealKind.Always, revealProblem: RevealProblemKind.Never, focus: false, panel: PanelKind.Shared, showReuseMessage: true, clear: false }; } diff --git a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts index 573b8b9e37442..4fc53e0bff856 100644 --- a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts @@ -654,8 +654,7 @@ export class TerminalTaskSystem implements ITaskSystem { let revealProblemPanel = terminal && (revealProblem === RevealProblemKind.OnProblem) && (startStopProblemMatcher.numberOfMatches > 0); if (revealProblemPanel) { this.panelService.openPanel(Constants.MARKERS_PANEL_ID); - } - if (terminal && !revealProblemPanel && (reveal === RevealKind.Silent) && ((exitCode !== 0) || (startStopProblemMatcher.numberOfMatches > 0) && startStopProblemMatcher.maxMarkerSeverity && + } else if (terminal && (reveal === RevealKind.Silent) && ((exitCode !== 0) || (startStopProblemMatcher.numberOfMatches > 0) && startStopProblemMatcher.maxMarkerSeverity && (startStopProblemMatcher.maxMarkerSeverity >= MarkerSeverity.Error))) { this.terminalService.setActiveInstance(terminal); this.terminalService.showPanel(false); @@ -689,8 +688,7 @@ export class TerminalTaskSystem implements ITaskSystem { let showProblemPanel = task.command.presentation && (task.command.presentation.revealProblem === RevealProblemKind.Always); if (showProblemPanel) { this.panelService.openPanel(Constants.MARKERS_PANEL_ID); - } - if (task.command.presentation && !showProblemPanel && (task.command.presentation.reveal === RevealKind.Always)) { + } else if (task.command.presentation && (task.command.presentation.reveal === RevealKind.Always)) { this.terminalService.setActiveInstance(terminal); this.terminalService.showPanel(task.command.presentation.focus); } From e087d54b068ed351ea0e563da0e30f5b55dd641f Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 9 Apr 2019 13:57:10 +0200 Subject: [PATCH 9/9] Fix spacing --- .../contrib/tasks/electron-browser/terminalTaskSystem.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts index bfd0a6154e6e6..0b727f13ce566 100644 --- a/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts @@ -164,7 +164,7 @@ export class TerminalTaskSystem implements ITaskSystem { constructor( private terminalService: ITerminalService, private outputService: IOutputService, - private panelService: IPanelService, + private panelService: IPanelService, private markerService: IMarkerService, private modelService: IModelService, private configurationResolverService: IConfigurationResolverService, private telemetryService: ITelemetryService,