You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OS and Version: Windows 11 Pro 22H2, build 22621.2428
VS Code Version: 1.83.1
C/C++ Extension Version: tried both 1.17.5 and 1.18.0
If using SSH remote, specify OS of remote machine: tried with both native Windows as well as a WSL remote (WSL 1.2.5.0 running Ubuntu 22.04.2 LTS).
Bug Summary and Steps to Reproduce
Bug Summary:
While editing c_cpp_properties.json, trying to add the "configurationProvider" property results in the current line and existing comments being deleted. Note that properties other than configurationProvider do not seem to have the same behaviour. It could be that this is the intended behaviour, however, it makes it difficult to browse the available values of the property.
Steps to reproduce:
Install the C/C++ extension
Open an empty folder
Use the Edit Configurations (JSON) command to create and open the c_cpp_properties.json configuration file
Try to add the property "configurationProvider", letting it be autocompleted to "configurationProvider": "". Alternatively, type it in manually.
Notice the property as well as any existing comments disappearing. Note that it seems to happen on saving the configuration file.
Expected behaviour: "configurationProvider": "" and comments not disappearing.
Configuration and Logs
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
// Random comment
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
]
}
],
"version": 4
}
C/C++ language server debug log:
LSP: cpptools/didChangeCppProperties (id: 46)
LSP: cpptools/didChangeCppProperties (id: 47)
LSP: cpptools/didChangeCppProperties (id: 48)
LSP: cpptools/didChangeCppProperties (id: 49)
C/C++ Configuration Warning:
[10/24/2023, 11:04:39 AM] For C++ source files, the cppStandard was changed from "c++17" to "".
[10/24/2023, 11:04:39 AM] For C source files, the cStandard was changed from "c11" to "".
Other Extensions
All other extensions are disabled, even though disabling them did not change the behaviour.
It probably shouldn't be modifying the document if a corrected ID could not be found. Also, it probably shouldn't be touching all configurations, as some of them may not be applicable to the current host (if that file is checked into a repo). And, when rewriting c_cpp_properties.json, it should try to preserve existing comments.
Hi Colen Garoutte-Carson (@Colengms), thanks a lot for the reply! Good to know that it is indeed a bug and that you already found a potential cause. :)
Activity
Colengms commentedon Oct 25, 2023
Hi Jyrij (@Jyrijoul) . Thanks for reporting this.
This appears to be related to the following bit of (rather old) code:
vscode-cpptools/Extension/src/LanguageServer/configurations.ts
Lines 1411 to 1418 in 8fbc56a
It probably shouldn't be modifying the document if a corrected ID could not be found. Also, it probably shouldn't be touching all configurations, as some of them may not be applicable to the current host (if that file is checked into a repo). And, when rewriting
c_cpp_properties.json, it should try to preserve existing comments.Jyrijoul commentedon Oct 30, 2023
Hi Colen Garoutte-Carson (@Colengms), thanks a lot for the reply! Good to know that it is indeed a bug and that you already found a potential cause. :)