monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

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

Open BusinessDuck opened this issue 2 years ago • 1 comments

Reproducible in vscode.dev or in VS Code Desktop?

  • [X] 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

BusinessDuck avatar Apr 10 '23 15:04 BusinessDuck

this also forces me to re-colorize the entire page each time I switch themes. is this going to be resolved in foreseeable future?

frankli0324 avatar Mar 04 '24 10:03 frankli0324