Skip to content

Commit

Permalink
Fix show task restore for sidebar terminal
Browse files Browse the repository at this point in the history
Fixes #93416
  • Loading branch information
alexr00 committed Mar 27, 2020
1 parent f04dce3 commit 92b9e7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts
Expand Up @@ -79,7 +79,7 @@ import { ITextEditorSelection, TextEditorSelectionRevealType } from 'vs/platform
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { find } from 'vs/base/common/arrays';
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
import { IViewsService } from 'vs/workbench/common/views';
import { IViewsService, IViewDescriptorService } from 'vs/workbench/common/views';
import { isWorkspaceFolder, TaskQuickPickEntry, QUICKOPEN_DETAIL_CONFIG, TaskQuickPick, QUICKOPEN_SKIP_CONFIG } from 'vs/workbench/contrib/tasks/browser/taskQuickPick';

const QUICKOPEN_HISTORY_LIMIT_CONFIG = 'task.quickOpen.history';
Expand Down Expand Up @@ -253,7 +253,8 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
@ITerminalInstanceService private readonly terminalInstanceService: ITerminalInstanceService,
@IRemotePathService private readonly remotePathService: IRemotePathService,
@ITextModelService private readonly textModelResolverService: ITextModelService,
@IPreferencesService private readonly preferencesService: IPreferencesService
@IPreferencesService private readonly preferencesService: IPreferencesService,
@IViewDescriptorService private readonly viewDescriptorService: IViewDescriptorService
) {
super();

Expand Down Expand Up @@ -1468,7 +1469,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
this.modelService, this.configurationResolverService, this.telemetryService,
this.contextService, this.environmentService,
AbstractTaskService.OutputChannelId, this.fileService, this.terminalInstanceService,
this.remotePathService,
this.remotePathService, this.viewDescriptorService,
(workspaceFolder: IWorkspaceFolder) => {
if (!workspaceFolder) {
return undefined;
Expand Down
14 changes: 9 additions & 5 deletions src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
Expand Up @@ -45,7 +45,7 @@ import { Schemas } from 'vs/base/common/network';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IRemotePathService } from 'vs/workbench/services/path/common/remotePathService';
import { env as processEnv, cwd as processCwd } from 'vs/base/common/process';
import { IViewsService } from 'vs/workbench/common/views';
import { IViewsService, IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/common/views';

interface TerminalData {
terminal: ITerminalInstance;
Expand Down Expand Up @@ -201,6 +201,7 @@ export class TerminalTaskSystem implements ITaskSystem {
private fileService: IFileService,
private terminalInstanceService: ITerminalInstanceService,
private remotePathService: IRemotePathService,
private viewDescriptorService: IViewDescriptorService,
taskSystemInfoResolver: TaskSystemInfoResolver,
) {

Expand Down Expand Up @@ -298,7 +299,8 @@ export class TerminalTaskSystem implements ITaskSystem {
if (!terminalData) {
return false;
}
if (this.isTaskVisible(task)) {
const isTerminalInPanel: boolean = this.viewDescriptorService.getViewLocation(TERMINAL_VIEW_ID) === ViewContainerLocation.Panel;
if (isTerminalInPanel && this.isTaskVisible(task)) {
if (this.previousPanelId) {
if (this.previousTerminalInstance) {
this.terminalService.setActiveInstance(this.previousTerminalInstance);
Expand All @@ -310,9 +312,11 @@ export class TerminalTaskSystem implements ITaskSystem {
this.previousPanelId = undefined;
this.previousTerminalInstance = undefined;
} else {
this.previousPanelId = this.panelService.getActivePanel()?.getId();
if (this.previousPanelId === TERMINAL_VIEW_ID) {
this.previousTerminalInstance = this.terminalService.getActiveInstance() ?? undefined;
if (isTerminalInPanel) {
this.previousPanelId = this.panelService.getActivePanel()?.getId();
if (this.previousPanelId === TERMINAL_VIEW_ID) {
this.previousTerminalInstance = this.terminalService.getActiveInstance() ?? undefined;
}
}
this.terminalService.setActiveInstance(terminalData.terminal);
if (CustomTask.is(task) || ContributedTask.is(task)) {
Expand Down

0 comments on commit 92b9e7f

Please sign in to comment.