From 4203aaa8200afa4fa6d51696f0621caafdedb152 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 20 Sep 2022 21:30:31 -0700 Subject: [PATCH 1/2] mark IAuthenticationService as delayed --- .../browser/authenticationService.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/vs/workbench/services/authentication/browser/authenticationService.ts b/src/vs/workbench/services/authentication/browser/authenticationService.ts index 921cfbcb8bae6..69cb0d2ba4862 100644 --- a/src/vs/workbench/services/authentication/browser/authenticationService.ts +++ b/src/vs/workbench/services/authentication/browser/authenticationService.ts @@ -16,7 +16,7 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; -import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { Severity } from 'vs/platform/notification/common/notification'; import { IProductService } from 'vs/platform/product/common/productService'; import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput'; @@ -163,9 +163,16 @@ const authenticationExtPoint = ExtensionsRegistry.registerExtensionPoint(); private _sessionAccessRequestItems = new Map(); private _accountBadgeDisposable = this._register(new MutableDisposable()); @@ -198,13 +205,6 @@ export class AuthenticationService extends Disposable implements IAuthentication @IQuickInputService private readonly quickInputService: IQuickInputService ) { super(); - this._placeholderMenuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, { - command: { - id: 'noAuthenticationProviders', - title: nls.localize('authentication.Placeholder', "No accounts requested yet..."), - precondition: ContextKeyExpr.false() - }, - }); authenticationExtPoint.setHandler((extensions, { added, removed }) => { added.forEach(point => { @@ -255,9 +255,9 @@ export class AuthenticationService extends Disposable implements IAuthentication this._authenticationProviders.set(id, authenticationProvider); this._onDidRegisterAuthenticationProvider.fire({ id, label: authenticationProvider.label }); - if (this._placeholderMenuItem) { - this._placeholderMenuItem.dispose(); - this._placeholderMenuItem = undefined; + if (placeholderMenuItem) { + placeholderMenuItem.dispose(); + placeholderMenuItem = undefined; } } @@ -275,7 +275,7 @@ export class AuthenticationService extends Disposable implements IAuthentication } if (!this._authenticationProviders.size) { - this._placeholderMenuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, { + placeholderMenuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, { command: { id: 'noAuthenticationProviders', title: nls.localize('loading', "Loading..."), @@ -735,4 +735,4 @@ export class AuthenticationService extends Disposable implements IAuthentication } } -registerSingleton(IAuthenticationService, AuthenticationService, false); +registerSingleton(IAuthenticationService, AuthenticationService, InstantiationType.Delayed); From d63b8b219daa0bd25e9336e4d599300c855b79f7 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 20 Sep 2022 21:40:42 -0700 Subject: [PATCH 2/2] explicitly set to Eager for language detection --- .../browser/languageDetectionWorkerServiceImpl.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts b/src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts index 1b50fc3011e08..1b3db8dbbfd33 100644 --- a/src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts +++ b/src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts @@ -11,7 +11,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { ILanguageService } from 'vs/editor/common/languages/language'; import { URI } from 'vs/base/common/uri'; import { isWeb } from 'vs/base/common/platform'; -import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { LanguageDetectionSimpleWorker } from 'vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker'; import { IModelService } from 'vs/editor/common/services/model'; import { SimpleWorkerClient } from 'vs/base/common/worker/simpleWorker'; @@ -149,6 +149,9 @@ export class LanguageDetectionService extends Disposable implements ILanguageDet return this._languageDetectionWorkerClient.detectLanguage(resource, biases, preferHistory, supportedLangs); } + // TODO: explore using the history service or something similar to provide this list of opened editors + // so this service can support delayed instantiation. This may be tricky since it seems the IHistoryService + // only gives history for a workspace... where this takes advantage of history at a global level as well. private initEditorOpenedListeners(storageService: IStorageService) { try { const globalLangHistroyData = JSON.parse(storageService.get(LanguageDetectionService.globalOpenedLanguagesStorageKey, StorageScope.PROFILE, '[]')); @@ -354,4 +357,5 @@ export class LanguageDetectionWorkerClient extends EditorWorkerClient { } } -registerSingleton(ILanguageDetectionService, LanguageDetectionService, false); +// For now we use Eager until we handle keeping track of history better. +registerSingleton(ILanguageDetectionService, LanguageDetectionService, InstantiationType.Eager);