microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.73k stars 29.1k forks source link

Token Helight Color Not Working Fine! #208869

Closed EinOnly closed 6 months ago

EinOnly commented 7 months ago

Type: Bug

I use the same settings in my windows laptop and mac. But vsccode in mac always show me the different syntax helight from windows. Windows version is exactily what I need and is correct helight. Bty, I find that inspect Editor tokens and scopes is different in macos vscode from windows.

language: C++ 17 Theme: GitHub Dark settings json:

       "editor.tokenColorCustomizations": {
        "enabled": true, // enable for all themes
        "textMateRules": [
            {
                "scope": "comment.block",
                "settings": {
                    "foreground": "#62c27a"
                }
            },
            {
                "scope": "entity.name.function.preprocessor",
                "settings": {
                    "foreground": "#b74fe0"
                }
            },
            {
                "scope": "entity.name.function.macros",
                "settings": {
                    "foreground": "#b74fe0"
                }
            },
            {
                "scope": "keyword.control.directive",
                "settings": {
                    "foreground": "#687f8d"
                }
            },
            {
                "scope": "entity.name.function",
                "settings": {
                    "foreground": "#dbd40c"
                }
            },
            {
                "scope": "string.quoted",
                "settings": {
                    "foreground": "#c8e4d8"
                }
            },
            {
                "scope": "variable.other.local",
                "settings": {
                    "foreground": "#fba741"
                }
            },
            {
                "scope": "constant.numeric",
                "settings": {
                    "foreground": "#788ee0"
                }
            },
            {
                "scope": "comment.line",
                "settings": {
                    "foreground": "#41de7d"
                }
            },
            {
                "scope": "punctuation.separator.namespace.access.cpp.cpp",
                "settings": {
                    "foreground": "#8993d3"
                }
            },
            {
                "scope": "entity.name.class",
                "settings": {
                    "foreground": "#1d1d1d"
                }
            }
        ]
    },

I try all :

 {
                "scope": "entity.name.function.preprocessor",
                "settings": {
                    "foreground": "#b74fe0"
                }
            },
            {
                "scope": "entity.name.function.macros",
                "settings": {
                    "foreground": "#b74fe0"
                }
            },
{
                "scope": "entity.name.function",
                "settings": {
                    "foreground": "#dbd40c"
                }
            },

Macros and functions show the same color and Scape in mac. And variables never be helighted.

VS Code version: Code 1.87.2 (Universal) (863d2581ecda6849923a2118d93a088b0745d9d6, 2024-03-08T15:21:31.043Z) OS version: Darwin arm64 23.3.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M2 Max (12 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|2, 2, 2| |Memory (System)|32.00GB (0.50GB free)| |Process Argv|--crash-reporter-id 1f5fcdd0-1d46-4d2c-8b1f-817b7e88448f| |Screen Reader|no| |VM|0%|
Extensions (20) Extension|Author (truncated)|Version ---|---|--- asciidoctor-vscode|asc|3.2.3 solidity|Jua|0.0.174 vscode-clang|mit|0.2.4 debugpy|ms-|2024.2.0 python|ms-|2024.2.1 vscode-pylance|ms-|2024.3.2 remote-ssh|ms-|0.109.0 remote-ssh-edit|ms-|0.86.0 cmake-tools|ms-|1.17.17 cpptools|ms-|1.20.0 cpptools-extension-pack|ms-|1.3.0 hexeditor|ms-|1.9.14 makefile-tools|ms-|0.9.10 remote-explorer|ms-|0.4.3 sqltools|mtx|0.28.1 sqltools-driver-mssql|mtx|0.4.2 shader|sle|1.1.5 cmake|twx|0.0.17 vim|vsc|1.27.2 json|Zai|2.0.2 (2 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 d34g3935:30971562 fegfb526:30981948 bg6jg535:30979843 ccp1r3:30993539 dsvsc020:30976470 pythonaic:30996667 dsvsc021:30996838 gd77d436:30999572 ```
aeschli commented 7 months ago

Can you also add a small code sample, and screenshots?

You say Editor tokens and scopes is different. How so? Can you take screenshots of the two?

EinOnly commented 7 months ago
Screenshot 2024-03-29 at 10 27 14 Screenshot 2024-03-29 at 10 27 46 Screenshot 2024-03-29 at 10 29 14 Screenshot 2024-03-29 at 10 30 17

It seems that some settings might be causing this outcome, and I've ruled out plugins. I've encountered similar results using the same project on Windows as well. This project can compile successfully.

EinOnly commented 6 months ago

Need more information?

aeschli commented 6 months ago

So what is wrong? All three screenshots show a function call and all of them are rendered with the same color as I would expect.

EinOnly commented 6 months ago

"vkEnumerateInstanceExtensionProperties(nullptr, &properties_count, nullptr)" is a function and it is rendered right. But the "VK_MAKE_VERSION(1, 0, 0)" is a macro which should be rendered as a "entity.name.function.preprocessor" instead of function call. And all the macros are rendered wrong.

aeschli commented 6 months ago

Syntax highlighting is only based on the structure of the program. It can't look up symbols and doesn't know that VK_MAKE_VERSION is macro.

To resolve symbols (possibly across files) a language server is needed. It will add 'semantic highlighting' on top of the syntax highlighting. Looking at your screenshots, there's no semantic highlighting active here.

If that's all properly configured, you will see a semantic token section showing up in the Inspect editor scopes.. hover