change setting to workbench.editor.untitled.languageDetection

This commit is contained in:
Tyler Leonhardt 2021-07-16 17:23:27 -07:00
parent 9d9a283d40
commit 466aac0488
No known key found for this signature in database
GPG key ID: 1BC2B6244363E77E
4 changed files with 14 additions and 35 deletions

View file

@ -93,6 +93,12 @@ const registry = Registry.as<IConfigurationRegistry>(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'],

View file

@ -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<IConfigurationRegistry>(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<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(LanguageDetectionService, LifecyclePhase.Eventually);

View file

@ -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<boolean>('languageDetection.enabled', { overrideIdentifier: e.getMode() })) {
if (!configurationService.getValue<boolean>('workbench.editor.untitled.languageDetection', { overrideIdentifier: e.getMode() })) {
return;
}
@ -129,3 +132,6 @@ export class LanguageDetectionService extends Disposable implements ILanguageDet
return vscodeLanguageId ?? undefined;
}
}
Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench)
.registerWorkbenchContribution(LanguageDetectionService, LifecyclePhase.Eventually);

View file

@ -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