Skip to content

Commit

Permalink
Have a boolean setting for tree sitter
Browse files Browse the repository at this point in the history
Part of #210475
  • Loading branch information
alexr00 committed Aug 7, 2024
1 parent 4a8eb1a commit 3d7948b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Event } from 'vs/base/common/event';
import { cancelOnDispose } from 'vs/base/common/cancellation';

const EDITOR_EXPERIMENTAL_PREFER_TREESITTER = 'editor.experimental.preferTreeSitter';
const EDITOR_TREESITTER_TELEMETRY = 'editor.experimental.treeSitterTelemetry';
const moduleLocationTreeSitter: AppResourcePath = `${nodeModulesPath}/@vscode/tree-sitter-wasm/wasm`;
const moduleLocationTreeSitterWasm: AppResourcePath = `${moduleLocationTreeSitter}/tree-sitter.wasm`;

Expand Down Expand Up @@ -322,7 +323,16 @@ export class TreeSitterTextModelService extends Disposable implements ITreeSitte
}

private _getSetting(): string[] {
return this._configurationService.getValue<string[]>(EDITOR_EXPERIMENTAL_PREFER_TREESITTER) || [];
const setting = this._configurationService.getValue<string[]>(EDITOR_EXPERIMENTAL_PREFER_TREESITTER);
if (setting && setting.length > 0) {
return setting;
} else {
const expSetting = this._configurationService.getValue<boolean>(EDITOR_TREESITTER_TELEMETRY);
if (expSetting) {
return ['typescript'];
}
}
return [];
}

private async _registerModelServiceListeners() {
Expand Down
6 changes: 6 additions & 0 deletions src/vs/editor/common/config/editorConfigurationSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ const editorConfiguration: IConfigurationNode = {
description: nls.localize('editor.experimental.asyncTokenizationVerification', "Controls whether async tokenization should be verified against legacy background tokenization. Might slow down tokenization. For debugging only."),
tags: ['experimental'],
},
'editor.experimental.treeSitterTelemetry': {
type: 'boolean',
default: false,
markdownDescription: nls.localize('editor.experimental.treeSitterTelemetry', "Controls whether tree sitter parsing should be turned on and telemetry collected. Setting `editor.experimental.preferTreeSitter` for specific languages will take precedence."),
tags: ['experimental']
},
'editor.language.brackets': {
type: ['array', 'null'],
default: null, // We want to distinguish the empty array from not configured.
Expand Down

0 comments on commit 3d7948b

Please sign in to comment.