Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode Semantic Tokens Sample Extension Does Not Work #10428

Open
colin-grant-work opened this issue Nov 17, 2021 · 3 comments
Open

VSCode Semantic Tokens Sample Extension Does Not Work #10428

colin-grant-work opened this issue Nov 17, 2021 · 3 comments
Assignees
Labels
editor issues related to the editor monaco issues related to monaco vscode issues related to VSCode compatibility

Comments

@colin-grant-work
Copy link
Contributor

colin-grant-work commented Nov 17, 2021

Feature Description:

On current master (29ebe4c), it appears that the VSCode semantic tokens sample extension does not work. It appears to activate successfully, but the code to provideDocumentSemanticTokens is never called. This is the case in all themes, even with the preference editor.SemanticHighlightingEnabled set to true.

VSCode:

image

Theia:

image

OS: RHEL7
Platform: Electron
Version: 29ebe4c

@colin-grant-work
Copy link
Contributor Author

After fixing a bug with the prefrence setting (#10511) and setting editor.semanticHighlighting.enabled to true, I can get to this screenshot:

image

There seem to be two problems remaining:

  • Theia's builtin themes do not have semanticHighlighting set to true, so the 'configuredByTheme' setting mostly equates to false, unlike in VSCode.
  • In VSCode, if you force semantic highlighting on a theme that doesn't support it, it appears that the editor is able to fall back to colors provided by the grammar for tokens whose semantic specification it doesn't understand. Theia fails and falls back to the default color (plain white, e.g.).

@colin-grant-work colin-grant-work self-assigned this Dec 7, 2021
@colin-grant-work
Copy link
Contributor Author

In VSCode, if you force semantic highlighting on a theme that doesn't support it, it appears that the editor is able to fall back to colors provided by the grammar for tokens whose semantic specification it doesn't understand. Theia fails and falls back to the default color (plain white, e.g.).

This seems to be a consequence of the way we consume Monaco. We use the IStandaloneThemeService(Impl):

export interface IStandaloneThemeService extends monaco.theme.IThemeService {
// https://github.com/theia-ide/vscode/blob/standalone/0.23.x/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts#L200
readonly _knownThemes: Map<string, IStandaloneTheme>;
setTheme(themeName: string): void;
setAutoDetectHighContrast(autoDetectHighContrast: boolean): void;
defineTheme(themeName: string, themeData: monaco.editor.IStandaloneThemeData): void;
getColorTheme(): IStandaloneTheme;
setColorMapOverride(colorMapOverride: monaco.color.Color[] | null): void;
}
export class StandaloneThemeServiceImpl implements IStandaloneThemeService {
readonly _knownThemes: Map<string, IStandaloneTheme>;
setTheme(themeName: string): void { }
setAutoDetectHighContrast(autoDetectHighContrast: boolean): void { }
defineTheme(themeName: string, themeData: monaco.editor.IStandaloneThemeData): void { }
getColorTheme(): IStandaloneTheme { }
setColorMapOverride(colorMapOverride: monaco.color.Color[] | null): void { }
}

Which implements a getTokenStyleMetadata() method:

https://github.com/microsoft/vscode/blob/224701f74d0f275bbe814f3689729ec323499478/src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts#L157-L169

that bottoms out here and returns the default editor colors, with no reference to the grammar:

https://github.com/microsoft/vscode/blob/224701f74d0f275bbe814f3689729ec323499478/src/vs/editor/common/modes/supports/tokenization.ts#L377

Internally, VSCode uses the ColorThemeData#getTokenStyleMetadata method:

https://github.com/microsoft/vscode/blob/224701f74d0f275bbe814f3689729ec323499478/src/vs/workbench/services/themes/common/colorThemeData.ts#L264-L277

Which bottoms out in a check for what the normal grammar color would have been:

https://github.com/microsoft/vscode/blob/224701f74d0f275bbe814f3689729ec323499478/src/vs/workbench/services/themes/common/colorThemeData.ts#L198-L217

Since we don't have access to that service in the current set up of our monaco package, we're missing that fallback.

@colin-grant-work
Copy link
Contributor Author

Theia's builtin themes do not have semanticHighlighting set to true, so the 'configuredByTheme' setting mostly equates to false, unlike in VSCode.

The StandaloneTheme implementation used by Theia's monaco integration sets all theme's semanticHighlighting to false, so updating the themes has no effect on that behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor issues related to the editor monaco issues related to monaco vscode issues related to VSCode compatibility
Projects
None yet
Development

No branches or pull requests

1 participant