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

Bug: Command C/C++: Select IntelliSense Configuration... -> Use g** #12705

Open
thernstig opened this issue Sep 12, 2024 · 2 comments
Open

Bug: Command C/C++: Select IntelliSense Configuration... -> Use g** #12705

thernstig opened this issue Sep 12, 2024 · 2 comments
Assignees
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service more info needed The issue report is not actionable in its current state

Comments

@thernstig
Copy link

Feature Request

Environment

  • OS and Version: Windows 11 23H2
  • VS Code Version: 1.92.2
  • C/C++ Extension Version: v1.21.6
  • If using SSH remote, specify OS of remote machine: wsl (Ubuntu 20.04)

Bug Summary and Steps to Reproduce

Bug Summary:
If you select a compiler via C/C++: Select IntelliSense Configuration... -> Use g** one can notice that the updated compilerPath is not updated until the second time you select the same command again. It then changes .vscode/c_cpp_properties.json to the compiler you selected in the n-1 try.

Inspelning.2024-09-12.142845.mp4

Steps to reproduce:

  1. Keep the .vscode/c_cpp_properties.json file open while changing the compiler via the command ``C/C++: Select IntelliSense Configuration....`
  2. Notice how it does not select what you chose.

Expected behavior:
It should format the file and add a new line at EOF.

Configuration and Logs

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c99",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        },
        {
            "name": "CMake",
            "compileCommands": "${config:cmake.buildDirectory}/compile_commands.json",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}
-------- Diagnostics - 9/4/2024, 1:10:29 PM
Version: 1.21.6
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/tobias/code/c-test/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/gcc",
    "cStandard": "c99",
    "cppStandard": "gnu++14",
    "intelliSenseMode": "linux-gcc-x64",
    "configurationProvider": "ms-vscode.cmake-tools",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/usr/bin/gcc",
    "configurationProviderInCppPropertiesJson": "ms-vscode.cmake-tools",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "/home/tobias/code/c-test/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": [
        "/home/tobias/code/c-test/src"
    ],
    "compilerPath": "/usr/bin/gcc",
    "compilerArgs": [],
    "compilerFragments": [
        "-g"
    ]
}
cpptools version (native): 1.21.6.0
Translation Unit Mappings:
[ /home/tobias/code/c-test/src/main.c - source TU]:
Translation Unit Configurations:
[ /home/tobias/code/c-test/src/main.c ]:
    Process ID: 30660
    Memory Usage: 15 MB
    Compiler Path: /usr/bin/gcc
    Includes:
    System Includes:
        /usr/lib/gcc/x86_64-linux-gnu/9/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c17
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=90400
Total Memory Usage: 15 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 4908

Other Extensions

No response

Additional context

No response

@sean-mcmanus
Copy link
Collaborator

@thernstig I believe that's "by design". The first time Select IntelliSense Configuration is used with gcc/g++ it will set the C_Cpp.default.compilerPath setting instead of creating/modifying a c_cpp_properties.json. If both C_Cpp.default.compilerPath and compilerPath in c_cpp_properties.json are set, then it will change the compilerPath in c_cpp_properties.json.

Did you want to use this issue to track formatting the c_cpp_properties.json and/or adding an EOL at the end? Does manually formatting have an affect? I think that behavior might be controlled by a json formatter or other VS Code setttings?

@sean-mcmanus sean-mcmanus self-assigned this Sep 12, 2024
@sean-mcmanus sean-mcmanus added Language Service more info needed The issue report is not actionable in its current state Feature: Configuration An issue related to configuring the extension or IntelliSense labels Sep 12, 2024
@thernstig
Copy link
Author

thernstig commented Sep 13, 2024

@sean-mcmanus but this happens if I change the C/C++: Select IntelliSense Configuration... multiple times in a row, it always changes to the n-1. Did you see the video I recorded?

Although what you describe still sounds very strange to me. I think it should only ever update c_cpp_properties.json and not the C_Cpp.default.compilerPath setting. That is unintuitive and unexpected, and could cause confusion to users. Then rather have a separate section under C/C++: Select IntelliSense Configuration... to set the default settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service more info needed The issue report is not actionable in its current state
Projects
Status: No status
Development

No branches or pull requests

2 participants