diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index 32af414acd3..f9ec7d26637 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -93,6 +93,12 @@ const registry = Registry.as(ConfigurationExtensions.Con 'default': 'text', 'markdownDescription': localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'untitledHint' }, "Controls if the untitled hint should be inline text in the editor or a floating button or hidden.") }, + 'workbench.editor.untitled.languageDetection': { + type: 'boolean', + default: false, + description: localize('workbench.editor.untitled.languageDetection', "Experimental. Controls whether the language in an untitled text editor is automatically detected. This can also be scoped by language so you can control which languages you want to trigger language detection on."), + scope: ConfigurationScope.LANGUAGE_OVERRIDABLE + }, 'workbench.editor.tabCloseButton': { 'type': 'string', 'enum': ['left', 'right', 'off'], diff --git a/src/vs/workbench/contrib/languageDetection/browser/languageDetection.contribution.ts b/src/vs/workbench/contrib/languageDetection/browser/languageDetection.contribution.ts deleted file mode 100644 index f930931453c..00000000000 --- a/src/vs/workbench/contrib/languageDetection/browser/languageDetection.contribution.ts +++ /dev/null @@ -1,31 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { localize } from 'vs/nls'; -import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; -import { Registry } from 'vs/platform/registry/common/platform'; -import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; -import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; -import { LanguageDetectionService } from 'vs/workbench/services/languageDetection/browser/languageDetectionService'; - -// Configuration -const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); -configurationRegistry.registerConfiguration({ - id: 'languageDetection', - order: 1025, - title: localize('languageDetectionConfigurationTitle', "Language Detection"), - type: 'object', - properties: { - 'languageDetection.enabled': { - type: 'boolean', - default: false, - description: localize('languageDetection.enabled', "Experimental. Controls whether the language in an untitled text editor is automatically detected."), - scope: ConfigurationScope.LANGUAGE_OVERRIDABLE - } - } -}); - -Registry.as(WorkbenchExtensions.Workbench) - .registerWorkbenchContribution(LanguageDetectionService, LifecyclePhase.Eventually); diff --git a/src/vs/workbench/services/languageDetection/browser/languageDetectionService.ts b/src/vs/workbench/services/languageDetection/browser/languageDetectionService.ts index 3f687dcc4fc..1eb823092da 100644 --- a/src/vs/workbench/services/languageDetection/browser/languageDetectionService.ts +++ b/src/vs/workbench/services/languageDetection/browser/languageDetectionService.ts @@ -13,6 +13,9 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IModeService } from 'vs/editor/common/services/modeService'; import { URI } from 'vs/base/common/uri'; import { isWeb } from 'vs/base/common/platform'; +import { Registry } from 'vs/platform/registry/common/platform'; +import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions'; +import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; export class LanguageDetectionService extends Disposable implements ILanguageDetectionService { private static readonly expectedConfidence = 0.6; @@ -29,7 +32,7 @@ export class LanguageDetectionService extends Disposable implements ILanguageDet super(); this._register(untitledTextEditorService.onDidChangeContent(async e => { - if (!configurationService.getValue('languageDetection.enabled', { overrideIdentifier: e.getMode() })) { + if (!configurationService.getValue('workbench.editor.untitled.languageDetection', { overrideIdentifier: e.getMode() })) { return; } @@ -129,3 +132,6 @@ export class LanguageDetectionService extends Disposable implements ILanguageDet return vscodeLanguageId ?? undefined; } } + +Registry.as(Extensions.Workbench) + .registerWorkbenchContribution(LanguageDetectionService, LifecyclePhase.Eventually); diff --git a/src/vs/workbench/workbench.common.main.ts b/src/vs/workbench/workbench.common.main.ts index 52a585f667d..7113ca945b4 100644 --- a/src/vs/workbench/workbench.common.main.ts +++ b/src/vs/workbench/workbench.common.main.ts @@ -96,6 +96,7 @@ import 'vs/workbench/services/authentication/browser/authenticationService'; import 'vs/workbench/services/hover/browser/hoverService'; import 'vs/workbench/services/experiment/common/experimentService'; import 'vs/workbench/services/outline/browser/outlineService'; +import 'vs/workbench/services/languageDetection/browser/languageDetectionService'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService'; @@ -320,7 +321,4 @@ import 'vs/workbench/contrib/workspace/browser/workspace.contribution'; // Workspaces import 'vs/workbench/contrib/workspaces/browser/workspaces.contribution'; -// Language Detection -import 'vs/workbench/contrib/languageDetection/browser/languageDetection.contribution'; - //#endregion