Skip to content

Commit 18247c0

Browse files
authored
if there are tasks to reconnect to, show terminal panel (microsoft#163598)
1 parent b6f4df8 commit 18247c0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/vs/workbench/contrib/terminal/browser/terminalService.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
2020
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
2121
import { ILogService } from 'vs/platform/log/common/log';
2222
import { INotificationService } from 'vs/platform/notification/common/notification';
23+
import { IStorageService, StorageScope, StorageTarget, WillSaveStateReason } from 'vs/platform/storage/common/storage';
2324
import { ICreateContributedTerminalProfileOptions, IShellLaunchConfig, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalExitReason, TerminalLocation, TerminalLocationString, TitleEventSource } from 'vs/platform/terminal/common/terminal';
2425
import { formatMessageForTerminal } from 'vs/platform/terminal/common/terminalStrings';
2526
import { iconForeground } from 'vs/platform/theme/common/colorRegistry';
@@ -29,6 +30,7 @@ import { IThemeService, Themable, ThemeIcon } from 'vs/platform/theme/common/the
2930
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
3031
import { VirtualWorkspaceContext } from 'vs/workbench/common/contextkeys';
3132
import { IEditableData, IViewsService } from 'vs/workbench/common/views';
33+
import { TaskSettingId } from 'vs/workbench/contrib/tasks/common/tasks';
3234
import { ICreateTerminalOptions, IRequestAddInstanceToGroupEvent, ITerminalEditorService, ITerminalExternalLinkProvider, ITerminalGroup, ITerminalGroupService, ITerminalInstance, ITerminalInstanceHost, ITerminalInstanceService, ITerminalLocationOptions, ITerminalService, ITerminalServiceNativeDelegate, TerminalConnectionState, TerminalEditorLocation } from 'vs/workbench/contrib/terminal/browser/terminal';
3335
import { getCwdForSplit } from 'vs/workbench/contrib/terminal/browser/terminalActions';
3436
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
@@ -156,6 +158,7 @@ export class TerminalService implements ITerminalService {
156158
constructor(
157159
@IContextKeyService private _contextKeyService: IContextKeyService,
158160
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
161+
@IStorageService private readonly _storageService: IStorageService,
159162
@ILogService private readonly _logService: ILogService,
160163
@IDialogService private _dialogService: IDialogService,
161164
@IInstantiationService private _instantiationService: IInstantiationService,
@@ -218,6 +221,21 @@ export class TerminalService implements ITerminalService {
218221
_lifecycleService.onBeforeShutdown(async e => e.veto(this._onBeforeShutdown(e.reason), 'veto.terminal'));
219222
_lifecycleService.onWillShutdown(e => this._onWillShutdown(e));
220223

224+
if (this._configurationService.getValue(TaskSettingId.Reconnection)) {
225+
// in order to reconnect to tasks, we have to show the panel
226+
const reconnectToTaskKey = 'reconnectToTasks';
227+
this._storageService.onWillSaveState((e) => {
228+
if (e.reason === WillSaveStateReason.SHUTDOWN) {
229+
this._storageService.store(reconnectToTaskKey, this.instances.some(i => i.shellLaunchConfig.type === 'Task'), StorageScope.WORKSPACE, StorageTarget.USER);
230+
}
231+
});
232+
if (this._storageService.getBoolean(reconnectToTaskKey, StorageScope.WORKSPACE)) {
233+
this._viewsService.openView(TERMINAL_VIEW_ID).then(() => {
234+
this._storageService.store(reconnectToTaskKey, false, StorageScope.WORKSPACE, StorageTarget.USER);
235+
});
236+
}
237+
}
238+
221239
// Create async as the class depends on `this`
222240
timeout(0).then(() => this._instantiationService.createInstance(TerminalEditorStyle, document.head));
223241
}

src/vs/workbench/contrib/terminal/browser/terminalView.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ export class TerminalViewPane extends ViewPane {
161161
}
162162
}
163163
}));
164-
165164
this._register(this.onDidChangeBodyVisibility(async visible => {
166165
this._viewShowing.set(visible);
167166
if (visible) {

0 commit comments

Comments
 (0)