mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
do not restart ext hosts if not needed (#194003)
This commit is contained in:
committed by
GitHub
parent
3fba5b2f64
commit
ca5f7d8d5b
@@ -6,6 +6,7 @@
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { CancellationError } from 'vs/base/common/errors';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { equals } from 'vs/base/common/objects';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
@@ -146,29 +147,35 @@ export class UserDataProfileManagementService extends Disposable implements IUse
|
||||
private async changeCurrentProfile(profile: IUserDataProfile, reloadMessage?: string): Promise<void> {
|
||||
const isRemoteWindow = !!this.environmentService.remoteAuthority;
|
||||
|
||||
if (!isRemoteWindow) {
|
||||
if (!(await this.extensionService.stopExtensionHosts(localize('switch profile', "Switching to a profile.")))) {
|
||||
// If extension host did not stop, do not switch profile
|
||||
if (this.userDataProfilesService.profiles.some(p => p.id === this.userDataProfileService.currentProfile.id)) {
|
||||
await this.userDataProfilesService.setProfileForWorkspace(toWorkspaceIdentifier(this.workspaceContextService.getWorkspace()), this.userDataProfileService.currentProfile);
|
||||
const shouldRestartExtensionHosts = this.userDataProfileService.currentProfile.id !== profile.id || !equals(this.userDataProfileService.currentProfile.useDefaultFlags, profile.useDefaultFlags);
|
||||
|
||||
if (shouldRestartExtensionHosts) {
|
||||
if (!isRemoteWindow) {
|
||||
if (!(await this.extensionService.stopExtensionHosts(localize('switch profile', "Switching to a profile.")))) {
|
||||
// If extension host did not stop, do not switch profile
|
||||
if (this.userDataProfilesService.profiles.some(p => p.id === this.userDataProfileService.currentProfile.id)) {
|
||||
await this.userDataProfilesService.setProfileForWorkspace(toWorkspaceIdentifier(this.workspaceContextService.getWorkspace()), this.userDataProfileService.currentProfile);
|
||||
}
|
||||
throw new CancellationError();
|
||||
}
|
||||
throw new CancellationError();
|
||||
}
|
||||
}
|
||||
|
||||
// In a remote window update current profile before reloading so that data is preserved from current profile if asked to preserve
|
||||
await this.userDataProfileService.updateCurrentProfile(profile);
|
||||
|
||||
if (isRemoteWindow) {
|
||||
const { confirmed } = await this.dialogService.confirm({
|
||||
message: reloadMessage ?? localize('reload message', "Switching a profile requires reloading VS Code."),
|
||||
primaryButton: localize('reload button', "&&Reload"),
|
||||
});
|
||||
if (confirmed) {
|
||||
await this.hostService.reload();
|
||||
if (shouldRestartExtensionHosts) {
|
||||
if (isRemoteWindow) {
|
||||
const { confirmed } = await this.dialogService.confirm({
|
||||
message: reloadMessage ?? localize('reload message', "Switching a profile requires reloading VS Code."),
|
||||
primaryButton: localize('reload button', "&&Reload"),
|
||||
});
|
||||
if (confirmed) {
|
||||
await this.hostService.reload();
|
||||
}
|
||||
} else {
|
||||
await this.extensionService.startExtensionHosts();
|
||||
}
|
||||
} else {
|
||||
await this.extensionService.startExtensionHosts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user