Skip to content

Commit

Permalink
fix presentation.reveal & focus for detected tasks
Browse files Browse the repository at this point in the history
- default values of the taskConfig.presentation object are not taken
into consideration when detected tasks are started. This pull request
fixes the bug.
- fixes #7547

Signed-off-by: Liang Huang <[email protected]>
  • Loading branch information
elaihau committed Apr 11, 2020
1 parent cb3db2a commit 4c62668
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/task/src/browser/task-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import {
TaskIdentifier,
DependsOrder,
RevealKind,
ApplyToKind
ApplyToKind,
TaskOutputPresentation
} from '../common';
import { TaskWatcher } from '../common/task-watcher';
import { ProvidedTaskConfigurations } from './provided-task-configurations';
Expand Down Expand Up @@ -701,10 +702,10 @@ export class TaskService implements TaskConfigurationClient {
const terminalId = matchedRunningTaskInfo.terminalId;
if (terminalId) {
const terminal = this.terminalService.getByTerminalId(terminalId);
if (terminal && task.presentation) {
if (task.presentation.focus) { // assign focus to the terminal if presentation.focus is true
if (terminal) {
if (TaskOutputPresentation.shouldSetFocusToTerminal(task)) { // assign focus to the terminal if presentation.focus is true
this.terminalService.open(terminal, { mode: 'activate' });
} else if (task.presentation.reveal === RevealKind.Always) { // show the terminal but not assign focus
} else if (TaskOutputPresentation.shouldAlwaysRevealTerminal(task)) { // show the terminal but not assign focus
this.terminalService.open(terminal, { mode: 'reveal' });
}
}
Expand Down Expand Up @@ -991,8 +992,8 @@ export class TaskService implements TaskConfigurationClient {
this.messageService.error('Task is already running in terminal');
return this.terminalService.open(terminalWidget, { mode: 'activate' });
}
if (taskInfo.config.presentation && taskInfo.config.presentation.reveal === RevealKind.Always) {
if (taskInfo.config.presentation.focus) { // assign focus to the terminal if presentation.focus is true
if (TaskOutputPresentation.shouldAlwaysRevealTerminal(taskInfo.config)) {
if (TaskOutputPresentation.shouldSetFocusToTerminal(taskInfo.config)) { // assign focus to the terminal if presentation.focus is true
widgetOpenMode = 'activate';
} else { // show the terminal but not assign focus
widgetOpenMode = 'reveal';
Expand Down
4 changes: 4 additions & 0 deletions packages/task/src/common/task-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export namespace TaskOutputPresentation {
return outputPresentation;
}

export function shouldAlwaysRevealTerminal(task: TaskCustomization): boolean {
return !task.presentation || task.presentation.reveal === undefined || task.presentation.reveal === RevealKind.Always;
}

export function shouldSetFocusToTerminal(task: TaskCustomization): boolean {
return !!task.presentation && !!task.presentation.focus;
}
Expand Down

0 comments on commit 4c62668

Please sign in to comment.