Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Xboooo opened this issue Dec 6, 2024 · 5 comments
Labels
bug Feature: Colorization fixed Check the Milestone for the release in which the fix is or will be available. Language Service regression A bug that didn't exist in a previous release world ready An issue relating string character encodings, localization translations, etc.
Milestone

Comments

@Xboooo
Copy link

Xboooo commented Dec 6, 2024

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

@sean-mcmanus sean-mcmanus added the world ready An issue relating string character encodings, localization translations, etc. label Dec 6, 2024
@Colengms
Copy link
Contributor

Colengms commented Dec 6, 2024

C/C++ Extension Version: 1.12.6

Hi @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)

@sean-mcmanus
Copy link
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.

@Colengms Colengms added more info needed The issue report is not actionable in its current state bug and removed bug more info needed The issue report is not actionable in its current state labels Dec 6, 2024
@Colengms Colengms moved this to Pull Request in cpptools Dec 6, 2024
@Colengms Colengms moved this from Pull Request to Done in cpptools Dec 6, 2024
@Colengms Colengms added the fixed Check the Milestone for the release in which the fix is or will be available. label Dec 6, 2024
@Colengms Colengms added this to the 1.23.3 milestone Dec 6, 2024
@Xboooo
Copy link
Author

Xboooo commented Dec 9, 2024

@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

@sean-mcmanus
Copy link
Contributor

@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.

@Xboooo
Copy link
Author

Xboooo commented Dec 10, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Feature: Colorization fixed Check the Milestone for the release in which the fix is or will be available. Language Service regression A bug that didn't exist in a previous release world ready An issue relating string character encodings, localization translations, etc.
Projects
Status: Done
Development

No branches or pull requests

3 participants