Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if there are tasks to reconnect to, show terminal panel #163598

Merged
merged 12 commits into from Oct 18, 2022
18 changes: 18 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalService.ts
Expand Up @@ -20,6 +20,7 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IStorageService, StorageScope, StorageTarget, WillSaveStateReason } from 'vs/platform/storage/common/storage';
import { ICreateContributedTerminalProfileOptions, IShellLaunchConfig, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalExitReason, TerminalLocation, TerminalLocationString, TitleEventSource } from 'vs/platform/terminal/common/terminal';
import { formatMessageForTerminal } from 'vs/platform/terminal/common/terminalStrings';
import { iconForeground } from 'vs/platform/theme/common/colorRegistry';
Expand All @@ -29,6 +30,7 @@ import { IThemeService, Themable, ThemeIcon } from 'vs/platform/theme/common/the
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { VirtualWorkspaceContext } from 'vs/workbench/common/contextkeys';
import { IEditableData, IViewsService } from 'vs/workbench/common/views';
import { TaskSettingId } from 'vs/workbench/contrib/tasks/common/tasks';
import { ICreateTerminalOptions, IRequestAddInstanceToGroupEvent, ITerminalEditorService, ITerminalExternalLinkProvider, ITerminalGroup, ITerminalGroupService, ITerminalInstance, ITerminalInstanceHost, ITerminalInstanceService, ITerminalLocationOptions, ITerminalService, ITerminalServiceNativeDelegate, TerminalConnectionState, TerminalEditorLocation } from 'vs/workbench/contrib/terminal/browser/terminal';
import { getCwdForSplit } from 'vs/workbench/contrib/terminal/browser/terminalActions';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
Expand Down Expand Up @@ -156,6 +158,7 @@ export class TerminalService implements ITerminalService {
constructor(
@IContextKeyService private _contextKeyService: IContextKeyService,
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
@IStorageService private readonly _storageService: IStorageService,
@ILogService private readonly _logService: ILogService,
@IDialogService private _dialogService: IDialogService,
@IInstantiationService private _instantiationService: IInstantiationService,
Expand Down Expand Up @@ -218,6 +221,21 @@ export class TerminalService implements ITerminalService {
_lifecycleService.onBeforeShutdown(async e => e.veto(this._onBeforeShutdown(e.reason), 'veto.terminal'));
_lifecycleService.onWillShutdown(e => this._onWillShutdown(e));

if (this._configurationService.getValue(TaskSettingId.Reconnection)) {
// in order to reconnect to tasks, we have to show the panel
const reconnectToTaskKey = 'reconnectToTasks';
this._storageService.onWillSaveState((e) => {
if (e.reason === WillSaveStateReason.SHUTDOWN) {
this._storageService.store(reconnectToTaskKey, this.instances.some(i => i.shellLaunchConfig.type === 'Task'), StorageScope.WORKSPACE, StorageTarget.USER);
}
});
if (this._storageService.getBoolean(reconnectToTaskKey, StorageScope.WORKSPACE)) {
this._viewsService.openView(TERMINAL_VIEW_ID).then(() => {
this._storageService.store(reconnectToTaskKey, false, StorageScope.WORKSPACE, StorageTarget.USER);
});
}
}

// Create async as the class depends on `this`
timeout(0).then(() => this._instantiationService.createInstance(TerminalEditorStyle, document.head));
}
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/contrib/terminal/browser/terminalView.ts
Expand Up @@ -161,7 +161,6 @@ export class TerminalViewPane extends ViewPane {
}
}
}));
meganrogge marked this conversation as resolved.
Show resolved Hide resolved

this._register(this.onDidChangeBodyVisibility(async visible => {
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
this._viewShowing.set(visible);
if (visible) {
Expand Down