提交 c25e7c1c 编写于 作者: M Martin Aeschlimann

[semantic] Allow to enable semantic highlighting for a language. Fixes #101292

上级 07462976
......@@ -503,8 +503,13 @@ const editorConfiguration: IConfigurationNode = {
description: nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.")
},
'editor.semanticHighlighting.enabled': {
type: 'boolean',
default: true,
enum: [true, false, 'configuredByTheme'],
enumDescriptions: [
nls.localize('semanticHighlighting.true', 'Semantic highlighting enabled for all color themes.'),
nls.localize('semanticHighlighting.false', 'Semantic highlighting disabled for all color themes.'),
nls.localize('semanticHighlighting.configuredByTheme', 'Semantic highlighting is configured by the current color theme\'s `semanticHighlighting` setting.')
],
default: 'configuredByTheme',
description: nls.localize('semanticHighlighting.enabled', "Controls whether the semanticHighlighting is shown for the languages that support it.")
},
'editor.stablePeek': {
......
......@@ -31,7 +31,7 @@ import { Schemas } from 'vs/base/common/network';
import { SemanticTokensProviderStyling, toMultilineTokens2 } from 'vs/editor/common/services/semanticTokensProviderStyling';
export interface IEditorSemanticHighlightingOptions {
enabled?: boolean;
enabled: true | false | 'configuredByTheme';
}
function MODEL_ID(resource: URI): string {
......@@ -633,11 +633,11 @@ export interface ILineSequence {
export const SEMANTIC_HIGHLIGHTING_SETTING_ID = 'editor.semanticHighlighting';
export function isSemanticColoringEnabled(model: ITextModel, themeService: IThemeService, configurationService: IConfigurationService): boolean {
if (!themeService.getColorTheme().semanticHighlighting) {
return false;
const setting = configurationService.getValue<IEditorSemanticHighlightingOptions>(SEMANTIC_HIGHLIGHTING_SETTING_ID, { overrideIdentifier: model.getLanguageIdentifier().language, resource: model.uri }).enabled;
if (typeof setting === 'boolean') {
return setting;
}
const options = configurationService.getValue<IEditorSemanticHighlightingOptions>(SEMANTIC_HIGHLIGHTING_SETTING_ID, { overrideIdentifier: model.getLanguageIdentifier().language, resource: model.uri });
return Boolean(options && options.enabled);
return themeService.getColorTheme().semanticHighlighting;
}
class SemanticColoringFeature extends Disposable {
......
......@@ -115,9 +115,12 @@ export interface IGlobalEditorOptions {
wordBasedSuggestions?: boolean;
/**
* Controls whether the semanticHighlighting is shown for the languages that support it.
* Defaults to true.
* true: semanticHighlighting is enabled for all themes
* false: semanticHighlighting is disabled for all themes
* 'configuredByTheme': semanticHighlighting is controlled by the current color theme's semanticHighlighting setting.
* Defaults to 'byTheme'.
*/
'semanticHighlighting.enabled'?: boolean;
'semanticHighlighting.enabled'?: true | false | 'configuredByTheme';
/**
* Keep peek editors open even when double clicking their content or when hitting `Escape`.
* Defaults to false.
......
......@@ -1117,9 +1117,12 @@ declare namespace monaco.editor {
wordBasedSuggestions?: boolean;
/**
* Controls whether the semanticHighlighting is shown for the languages that support it.
* Defaults to true.
* true: semanticHighlighting is enabled for all themes
* false: semanticHighlighting is disabled for all themes
* 'configuredByTheme': semanticHighlighting is controlled by the current color theme's semanticHighlighting setting.
* Defaults to 'byTheme'.
*/
'semanticHighlighting.enabled'?: boolean;
'semanticHighlighting.enabled'?: true | false | 'configuredByTheme';
/**
* Keep peek editors open even when double clicking their content or when hitting `Escape`.
* Defaults to false.
......
......@@ -29,10 +29,7 @@ import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { ColorThemeData, TokenStyleDefinitions, TokenStyleDefinition, TextMateThemingRuleDefinitions } from 'vs/workbench/services/themes/common/colorThemeData';
import { SemanticTokenRule, TokenStyleData, TokenStyle } from 'vs/platform/theme/common/tokenClassificationRegistry';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export interface IEditorSemanticHighlightingOptions {
enabled?: boolean;
}
import { SEMANTIC_HIGHLIGHTING_SETTING_ID, IEditorSemanticHighlightingOptions } from 'vs/editor/common/services/modelServiceImpl';
class InspectEditorTokensController extends Disposable implements IEditorContribution {
......@@ -264,11 +261,11 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
}
private _isSemanticColoringEnabled() {
if (!this._themeService.getColorTheme().semanticHighlighting) {
return false;
const setting = this._configurationService.getValue<IEditorSemanticHighlightingOptions>(SEMANTIC_HIGHLIGHTING_SETTING_ID, { overrideIdentifier: this._model.getLanguageIdentifier().language, resource: this._model.uri }).enabled;
if (typeof setting === 'boolean') {
return setting;
}
const options = this._configurationService.getValue<IEditorSemanticHighlightingOptions>('editor.semanticHighlighting', { overrideIdentifier: this._model.getLanguageIdentifier().language, resource: this._model.uri });
return options && options.enabled;
return this._themeService.getColorTheme().semanticHighlighting;
}
private _compute(grammar: IGrammar | null, semanticTokens: SemanticTokensResult | null, position: Position): string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册