Skip to content

In large-scale C/C+projects, the GB2312 encoding format will affect intelligent perception #13028

Closed

Description

@Xboooo

Environment

  • OS and Version: windows 10
  • VS Code Version: 1.95.3
  • C/C++ Extension Version: 1.12.6
  • If using SSH remote, specify OS of remote machine: Ubuntu 18.04.5 LTS

Bug Summary and Steps to Reproduce

I found that in my large C/C++project, all annotations containing Chinese (GB2312) can affect intelligent perception, and the color rendering of the code is also incorrect. At this time, my setting is "files. encoding": "gb2312"

After deleting "files. encoding": "gb2312" and "files. autoGuessEncoding": true, it looks a bit normal now, but the intelligent perception is still not good

For example, when jumping to a function, it can only jump to the. h file. However, when I modified the corresponding. c file to convert it to UTF-8 format, it worked properly

I am confused whether this is a problem with vscode or cpptools

Configuration and Logs

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/opt/rv1106-rockit/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}

{
  "os": "linux",
  "vscodeVersion": "1.95.3",
  "cmtVersion": "1.19.52",
  "configurations": [
    {
      "folder": "/home/caixiangbo/work/ipc_new",
      "cmakeVersion": "3.27.6",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": false,
      "compilers": {
        "C": "/opt/rv1126-rockit/arm-rockchip830-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc",
        "CXX": "/opt/rv1126-rockit/arm-rockchip830-linux-gnueabihf/bin/arm-linux-gnueabihf-g++"
      }
    },
    {
      "folder": "/home/caixiangbo/work/APP_4G",
      "cmakeVersion": "3.27.6",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": false,
      "compilers": {
        "C": "/opt/rv1106-rockit/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc",
        "CXX": "/opt/rv1106-rockit/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-g++"
      }
    },
    {
      "folder": "/home/caixiangbo/work/protocol",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/caixiangbo/work/test_project",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/caixiangbo/progs",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/caixiangbo/opensource",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "RelWithDebInfo",
    "buildTypesSeen": [
      "RelWithDebInfo"
    ],
    "requests": [
      "file:///home/caixiangbo/work/ipc_new/module/src/mmhp_public.c"
    ],
    "responses": [],
    "partialMatches": [],
    "targetCount": 25,
    "executablesCount": 3,
    "librariesCount": 22,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

The following log shows that I go to the "p_com_is_enet_channelid" interface, but did not successfully redirect and only displayed a few locations where this interface was called

LSP: (received) textDocument/definition: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 344)
LSP: (invoked) textDocument/definition: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 344)
LSP: Sending response (id: 344)
LSP: (received) cpptools/didChangeActiveEditor: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeActiveEditor: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) textDocument/documentHighlight: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 345)
LSP: (invoked) textDocument/documentHighlight: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 345)
LSP: Sending response (id: 345)
LSP: (received) textDocument/definition: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 346)
LSP: (invoked) textDocument/definition: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 346)
LSP: Sending response (id: 346)
LSP: (received) cpptools/getCodeActions: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 347)
LSP: (invoked) cpptools/getCodeActions: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 347)
LSP: Sending response (id: 347)
LSP: (received) cpptools/findAllReferences: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 348)
LSP: (invoked) cpptools/findAllReferences: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 348)
LSP: Sending response (id: 348)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (received) textDocument/documentHighlight: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 349)
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (invoked) textDocument/documentHighlight: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 349)
LSP: $/cancelRequest (textDocument/documentHighlight, id: 349)
LSP: (received) cpptools/getCodeActions: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 350)
LSP: (received) cpptools/getFoldingRanges: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 351)
LSP: (received) cpptools/getDocumentSymbols: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 352)
LSP: (invoked) cpptools/getDocumentSymbols: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 352)
LSP: Sending response (id: 352)
LSP: (invoked) cpptools/getCodeActions: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 350)
LSP: Sending response (id: 350)
LSP: (invoked) cpptools/getFoldingRanges: file:///home/caixiangbo/work/ipc_new/module/src/mmhp_powerboard.c (id: 351)
LSP: Sending response (id: 351)

Other Extensions

No response

Additional context

No response

Activity

  1. Colengms commented on Dec 6, 2024

    @Colengms
    Contributor

    C/C++ Extension Version: 1.12.6

    Hi Dr.bo (@Xboooo) . Do you also see the problem with the latest insiders, 1.23.2 ?

    Note that autoGuessEncoding is not supported by the C/C++ Extension when reading header files that are not open in the editor. #4753 I believe in order for gb2312 encoded files to be read correctly as headers, you would need to set "files.encoding": "gb2312". However, it's possible that might conflict with other non-gb2312 files. #11407 (comment)

  2. sean-mcmanus commented on Dec 6, 2024

    @sean-mcmanus
    Contributor

    Minimal repro is with "files.encoding": "gb2312", and files of that encoding (Change File Encoding command "Save With Encoding").

    test1.cpp

    #include "test1.h"
    
    int main()
    {
        return 这;
    }

    test1.h

    int 这;

    Image

    The errors go away after the header is opened.

    I repro it in 1.18.5 from a year ago so it doesn't appear to be a regression.

  3. added
    more info neededThe issue report is not actionable in its current state
    and removed
    more info neededThe issue report is not actionable in its current state
    on Dec 6, 2024
  4. moved this from Pull Request to Done in cpptoolson Dec 6, 2024
  5. Xboooo commented on Dec 9, 2024

    @Xboooo
    Author

    Sean McManus (@sean-mcmanus) I see that you can reproduce this problem. Is there anything I can help with? I'm happy to help you solve this problem

  6. sean-mcmanus commented on Dec 10, 2024

    @sean-mcmanus
    Contributor

    Dr.bo (@Xboooo) The fix will be available in our next release, but due to the holidays I don't think we're releasing another update until January unless there's a severe enough regression bug.

  7. Xboooo commented on Dec 10, 2024

    @Xboooo
    Author

    Sean McManus (@sean-mcmanus) Merry Christmas🎉! Enjoy your vacation to the fullest, I have returned the version to "v1.16.3" which can now avoid this defect

  8. sean-mcmanus commented on Jan 10, 2025

    @sean-mcmanus
    Contributor
  9. Xboooo commented on Jan 12, 2025

    @Xboooo
    Author

    Sean McManus (@sean-mcmanus) I tried the pre-release version v1.12.3, and it seems to have been fully fixed

  10. heartacker commented on Jan 12, 2025

    @heartacker
    Contributor

    great

  11. Yingzi1234 commented on Jan 27, 2025

    @Yingzi1234

    Sean McManus (@sean-mcmanus) This issue has been fixed on latest C/C++ version 1.23.4(pre-release), you can get the details below. Thank you!

    Image

  12. locked and limited conversation to collaborators on Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: ColorizationLanguage ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.regressionA bug that didn't exist in a previous releaseworld readyAn issue relating string character encodings, localization translations, etc.

    Type

    Projects

    • Status
      Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions