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
Since version 0.1.25 (which replaced the old behavior of highlighting regions with the default comment color) the vscode-clangd extension does not clear either background highlights or lowered opacity of inactive code before reloading the server. Background highlights or opacity are re-applied to the code (additively in case of the background highlight). Additionally, if the inactive code changed during the reload due to using a new compile_commands.json or edits to the existing one, code can be highlighted as inactive even while it is active.
As an example, consider the following C++ program:
#include<iostream>
#ifdef A
#defineMESSAGE"Howdy A!"
#else
#ifdef B
#defineMESSAGE"Hello B!"
#else
#error "A or B must be defined"
#endif
#endifintmain() {
std::cout << MESSAGE << std::endl;
}
and the following (handwritten for simplicity) compile_commands.json:
When loading a folder containing these two files in VSCode, vscode-clangd properly marks the inactive regions:
If we now change -DA to -DB in compile_commands.json and run clangd.restart the highlights from -DA persist:
For completeness, this also works on the "error" branch if we drop the define entirely:
This behaves similarly if the clangd.inactiveRegions.useBackgroundHighlight setings is enabled, but the highlights appear to stack, getting darker as you repeatedly reload, even without changing the compile_commands.json file.
My hunch is that this occurs because there is no code to clear the regions in the dispose method, but I'm very new to VSCode extension development so I am unsure I'm understanding the root cause properly.
Logs clangd.log
(Covers walking through the same steps as shown in the example)
System information
Clangd version (from the log, or clangd --version): 17.0.3
clangd extension version: 0.1.27-0.1.25 (tested with all 3 versions)
Operating system: Linux x86-64, using remote development through a Windows 10 machine (though I think that isn't relevant here?)
The text was updated successfully, but these errors were encountered:
Since version 0.1.25 (which replaced the old behavior of highlighting regions with the default comment color) the
vscode-clangd
extension does not clear either background highlights or lowered opacity of inactive code before reloading the server. Background highlights or opacity are re-applied to the code (additively in case of the background highlight). Additionally, if the inactive code changed during the reload due to using a newcompile_commands.json
or edits to the existing one, code can be highlighted as inactive even while it is active.As an example, consider the following C++ program:
and the following (handwritten for simplicity)
compile_commands.json
:When loading a folder containing these two files in VSCode,
vscode-clangd
properly marks the inactive regions:If we now change
-DA
to-DB
incompile_commands.json
and runclangd.restart
the highlights from-DA
persist:For completeness, this also works on the "error" branch if we drop the define entirely:
This behaves similarly if the
clangd.inactiveRegions.useBackgroundHighlight
setings is enabled, but the highlights appear to stack, getting darker as you repeatedly reload, even without changing thecompile_commands.json
file.My hunch is that this occurs because there is no code to clear the regions in the dispose method, but I'm very new to VSCode extension development so I am unsure I'm understanding the root cause properly.
Logs
clangd.log
(Covers walking through the same steps as shown in the example)
System information
Clangd version (from the log, or
clangd --version
): 17.0.3clangd extension version: 0.1.27-0.1.25 (tested with all 3 versions)
Operating system: Linux x86-64, using remote development through a Windows 10 machine (though I think that isn't relevant here?)
The text was updated successfully, but these errors were encountered: