mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-19 23:07:09 -05:00
rename language detection setting and ensure one worker gets created
This commit is contained in:
@@ -20,7 +20,7 @@ suite('vscode - untitled automatic language detection', () => {
|
||||
|
||||
assert.strictEqual(editor.document.languageId, 'plaintext');
|
||||
|
||||
const settingResult = vscode.workspace.getConfiguration().get<boolean>('workbench.editor.untitled.experimentalLanguageDetection');
|
||||
const settingResult = vscode.workspace.getConfiguration().get<boolean>('workbench.editor.untitled.languageDetection');
|
||||
assert.ok(settingResult);
|
||||
|
||||
const result = await editor.edit(editBuilder => {
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
"**/files-exclude/**": true
|
||||
},
|
||||
"editor.minimap.enabled": false, // see https://github.com/microsoft/vscode/issues/115747
|
||||
"workbench.editor.untitled.experimentalLanguageDetection": true
|
||||
"workbench.editor.untitled.languageDetection": true
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ 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.experimentalLanguageDetection': {
|
||||
'workbench.editor.untitled.languageDetection': {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: localize('workbench.editor.untitled.languageDetection', "Experimental. Controls whether the language in an untitled text editor is automatically detected unless the language has been explicitly set by the language picker. This can also be scoped by language so you can control which languages you want to trigger language detection on."),
|
||||
|
||||
@@ -21,7 +21,7 @@ import { EditorWorkerClient, EditorWorkerHost } from 'vs/editor/common/services/
|
||||
const moduleLocation = '../../../../../../node_modules/@vscode/vscode-languagedetection';
|
||||
const moduleLocationAsar = '../../../../../../node_modules.asar/@vscode/vscode-languagedetection';
|
||||
export class LanguageDetectionService extends Disposable implements ILanguageDetectionService {
|
||||
static readonly enablementSettingKey = 'workbench.editor.untitled.experimentalLanguageDetection';
|
||||
static readonly enablementSettingKey = 'workbench.editor.untitled.languageDetection';
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
@@ -124,7 +124,7 @@ export class LanguageDetectionWorkerHost {
|
||||
}
|
||||
|
||||
export class LanguageDetectionWorkerClient extends EditorWorkerClient {
|
||||
private worker: IWorkerClient<LanguageDetectionSimpleWorker> | undefined;
|
||||
private workerPromise: Promise<IWorkerClient<LanguageDetectionSimpleWorker>> | undefined;
|
||||
|
||||
constructor(
|
||||
modelService: IModelService,
|
||||
@@ -136,20 +136,24 @@ export class LanguageDetectionWorkerClient extends EditorWorkerClient {
|
||||
super(modelService, true, 'languageDetectionWorkerService');
|
||||
}
|
||||
|
||||
private _getOrCreateLanguageDetectionWorker(): IWorkerClient<LanguageDetectionSimpleWorker> {
|
||||
if (!this.worker) {
|
||||
private _getOrCreateLanguageDetectionWorker(): Promise<IWorkerClient<LanguageDetectionSimpleWorker>> {
|
||||
if (this.workerPromise) {
|
||||
return this.workerPromise;
|
||||
}
|
||||
|
||||
this.worker = this._register(new SimpleWorkerClient<LanguageDetectionSimpleWorker, EditorWorkerHost>(
|
||||
this.workerPromise = new Promise((resolve, reject) => {
|
||||
resolve(this._register(new SimpleWorkerClient<LanguageDetectionSimpleWorker, EditorWorkerHost>(
|
||||
this._workerFactory,
|
||||
'vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker',
|
||||
new EditorWorkerHost(this)
|
||||
));
|
||||
}
|
||||
return this.worker;
|
||||
)));
|
||||
});
|
||||
|
||||
return this.workerPromise;
|
||||
}
|
||||
|
||||
override async _getProxy(): Promise<LanguageDetectionSimpleWorker> {
|
||||
return await this._getOrCreateLanguageDetectionWorker().getProxyObject();
|
||||
return (await this._getOrCreateLanguageDetectionWorker()).getProxyObject();
|
||||
}
|
||||
|
||||
// foreign host request
|
||||
|
||||
Reference in New Issue
Block a user