microsoft / microsoft/monaco-editor

[Bug] Runtime theme change produces incorrect strings highlighting inside of colorize element

Open
#3,906 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug tokenization
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.37.1#XQAAAAIvAwAAAAAAAABBqQkHQ5NjdzoumDVN8LxZJobd5XiRz5ps84BErOQhAuGNY2A_2VKJa2dGL1BKMQB9wWZacsB87XX2r0ubgXD85SdrGNr5E9kC12nAZ2rcViXl84HjsGE8hLGMjJceiI7yZ_Yw2ppYAQCpULIRJvPjQFv9fTvm3D_dOMeXgYc-EJ6nDruHF0zHx9C5a1eoj3D2juCpLF3YolOasup0X5rU41FZJJhISuIW0pfqGiBcc2jgV42o4w0SsgeNgd1VO6ijQfAulSWpxs8N3yiEas2V_hTCASN_vJOCKRqpIMCVRjNHr2MThM85RO_26gtbYwGh5YmM1V0AJIZrtmwR-UwFOSpOxIX7tqGbIY1V2BbfabKlS4b5ScOWm00bXmLD1o4FcwSwc80wtMde0WCmldpw0S3SFH_9Y8iQBvI4pXOFXNttAfmxHFmHuRAXUBgmZGBR4yclMpuHsdQuxCWTK1Qj_PpkFAl6clmmUZgDUM0aF6_LuIi6TcL-NZRCNYAKhMHFmwFDA_L6UAUBHBXRwBDfvr5vDUwXV6-BU7_YgJPxtxk6Ws3MfmvjLG9Cf7F0LvcFg4dTHz27tdZ3IHDzPoOeWNiNrGWZKGW4LhVkR6oBpIC1TZLX7Db7E3SoB06ydBDBdm_zQjOkukPUiJGdCMfQsjMY-9vQp50GzQNUv7-R_MZz2WdNe7LY8L9Hb-YaFMD_5on5DA

Monaco Editor Playground Code
// The colorizeElement-function will read the data-lang-attribute
// from the element to select the correct language mode. In this
// sample it is text/css.
monaco.editor.colorizeElement(document.getElementById("code"), { theme: 'vs-light' });

setTimeout(() => {
	monaco.editor.setTheme('vs-dark');
}, 1000)
Reproduction Steps
  • Colorize element using monaco.editor.colorizeElement
  • Change theme in runtime from 'vs-light' to 'vs-dark' (working with any couple of themes)
Actual (Problematic) Behavior

all of "String" kind tokens will have a red color.

Expected Behavior

Expected: all of "String" kind tokens will have a themed color for current token kind.

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Monaco Editor Playground and reproduce the issue using monaco.editor.colorizeElement, then switch themes with monaco.editor.setTheme. Trace how the colorized element handles the runtime theme update; done means String tokens use the current theme's token color instead of turning red.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.