Skip to content

Syntax highlight multi-editor issue #8867

Description

@mmlacak

Bug type: Language Service

Describe the bug

  • OS and Version: 64-bit Fedora 35, with all latest patches
    Linux localhost.localdomain 5.15.16-200.fc35.x86_64 #\1 SMP Thu Jan 20 15:38:18 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • VS Code Version:
    Version: 1.64.2
    Commit: f80445acd5a3dadef24aa209168452a3d97cc326
    Date: 2022-02-09T22:02:29.527Z
    Electron: 13.5.2
    Chromium: 91.0.4472.164
    Node.js: 14.16.0
    V8: 9.1.269.39-electron.0
    OS: Linux x64 5.15.16-200.fc35.x86_64
  • C/C++ Extension Version: Version 1.8.4: February 7, 2022
  • Other extensions you installed (and if the issue persists after disabling them):N/A
  • If using SSH remote, specify OS of remote machine: N/A
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).
    With 2 side-by-side editors, syntax highlight in a non-focused editor (after any edit, save in a focused editor), switches to default syntax highlighting (i.e. the one without C/C++ extension).
    Workspace is a single project having LaTeX, Python and C files, size:
    Totals grouped by language (dominant language first):
    python: 10845 (52.50%)
    ansic: 9769 (47.29%)
    sh: 43 (0.21%)
    LaTex is not picked up by sloccount, I estimate it to be around 5k-6k lines.
    Whole project is available at: https://github.com/mmlacak/crochess.

Steps to reproduce

  1. install+enable MS C/C++ extension (without it all syntax highlighting is always the same, default one)
  2. open 2 editors side by side
  3. in left editor open C file
  4. in right editor open H file --> both editors show new (correct) syntax highlighting (must use H file, if C file is used, coloring remains the new, correct one)
  5. make some small change in C code -> H editor changes coloring to default (the one without C/C++ extension)
  6. save C file --> H editor briefly shows correct syntax highlight, then reverts back to default
  7. if H editor is focused (by clicking it, or tab), it switches to correct, new syntax highlighting

Works the other way around, if H file is edited and saved, then C file editor switches to default coloring (as if without C/C++ extension).

Expected behavior

All C and H files retain their new syntax highlight at all times, regardless of any editing, saving, ...

Code sample and logs

  • Code sample
    Works with any correct (parseable) C, H files.

  • Configurations in c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${default}",
                "${workspaceFolder}/ws/libcrochess/inc",
                "${workspaceFolder}/ws/crochess/inc",
                "${workspaceFolder}/ws/tests/inc"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-clang-x64"
        }
    ],
    "version": 4
}
  • Logs from running C/C++: Log Diagnostics from the VS Code command palette
-------- Diagnostics - 2/15/2022, 4:31:30 PM
Version: 1.8.4
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspace}/ws/libcrochess/inc",
        "${workspace}/ws/crochess/inc",
        "${workspace}/ws/tests/inc",
        "${default}",
        "${workspaceFolder}/ws/libcrochess/inc",
        "${workspaceFolder}/ws/crochess/inc",
        "${workspaceFolder}/ws/tests/inc"
    ],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++14",
    "intelliSenseMode": "linux-clang-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerArgs": [],
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "${workspace}/ws/libcrochess/inc",
            "${workspace}/ws/crochess/inc",
            "${workspace}/ws/tests/inc",
            "${default}",
            "${workspaceFolder}/ws/libcrochess/inc",
            "${workspaceFolder}/ws/crochess/inc",
            "${workspaceFolder}/ws/tests/inc",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c ]:
    /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h *
    /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
Translation Unit Configurations:
[ /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c ]:
    Process ID: 20167
    Memory Usage: 16 MB
    Compiler Path: /usr/bin/clang
    Includes:
        /home/pero/src/crochess/ws/libcrochess/inc
        /home/pero/src/crochess/ws/crochess/inc
        /home/pero/src/crochess/ws/tests/inc
        /usr/lib64/clang/13.0.0/include
        /usr/local/include
        /usr/include
    Standard Version: c17
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=130000
Total Memory Usage: 16 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 7467
Number of files parsed: 589
loggingLevel: Debug
loggingLevel has changed to: Debug
cpptools/didChangeCppProperties
$/setTraceNotification
cpptools/getCodeActions: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 82)
cpptools/textEditorSelectionChange
cpptools/activeDocumentChange: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 83)
textDocument/hover: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 84)
textDocument/hover: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 85)
textDocument/hover: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 86)
textDocument/didChange: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
cpptools/textEditorSelectionChange
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 87)
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 88)
cpptools/getDocumentSymbols: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 89)
cpptools/getDocumentSymbols
Checking for syntax errors: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
Queueing IntelliSense update for files in translation unit of: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
  tag parsing file: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
sending 1 changes to server
cpptools/finishUpdateSquiggles
Error squiggle count: 0
Error squiggle count: 0
Update IntelliSense time (sec): 2.355
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 90)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 91)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 92)
textDocument/didChange: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
cpptools/textEditorSelectionChange
willSaveWaitUntil: 0ms
textDocument/didSave: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
  tag parsing file: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
cpptools/fileChanged: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 94)
idle loop: reparsing the active document
Checking for syntax errors: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
Queueing IntelliSense update for files in translation unit of: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 95)
sending 1 changes to server
cpptools/finishUpdateSquiggles
Error squiggle count: 0
Error squiggle count: 0
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 96)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 97)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 98)
cpptools/getDocumentSymbols: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 99)
cpptools/getDocumentSymbols
Checking for syntax errors: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
Queueing IntelliSense update for files in translation unit of: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
cpptools/finishUpdateSquiggles
Error squiggle count: 0
Error squiggle count: 0
Update IntelliSense time (sec): 2.259
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 100)
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 101)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 102)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 103)
textDocument/hover: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 104)
textDocument/hover: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 105)
cpptools/textEditorSelectionChange
cpptools/activeDocumentChange: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h
idle loop: reparsing the active document
Checking for syntax errors: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h
Queueing IntelliSense update for files in translation unit of: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
cpptools/finishUpdateSquiggles
Error squiggle count: 0
Error squiggle count: 0
Update IntelliSense time (sec): 0.257
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 106)
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 107)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 108)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 109)
textDocument/hover: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 110)
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/activeDocumentChange: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
idle loop: reparsing the active document
Checking for syntax errors: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
Queueing IntelliSense update for files in translation unit of: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c
cpptools/finishUpdateSquiggles
Error squiggle count: 0
Error squiggle count: 0
Update IntelliSense time (sec): 0.257
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 111)
cpptools/getSemanticTokens: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 112)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/inc/cc_ply.h (id: 113)
cpptools/getFoldingRanges: /home/pero/src/crochess/ws/libcrochess/src/cc_ply.c (id: 114)

Screenshots

Screenshot from 2022-02-15 15-42-21

Additional context

N/A

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions