-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Do colorization of inactive preprocessor blocks #1466
Comments
I’m really looking forward to the next release. |
@hyeonchang You can try a preview .vsix at https://github.com/Microsoft/vscode-cpptools/releases/tag/v0.15.0-insiders (the final version is planned for next week). A couple things to note: for this feature to work, the intelliSenseEngine has to be "Default" and the red flame has to be gone (IntelliSense has to finish processing). |
The color is currently hardcoded at |
Oh, I misread your comment -- I don't know how to change the "background" color (does VS Code allow that?). I thought you were referring to the text color itself. |
@sean-mcmanus Sorry, I'm probably ignorant, but: a) Can this be disabled, or b) is there a way to "bootstrap" IntelliSense with symbols? The thing is, our make-based build system deduces the effective set of symbols from parameters to make (something like "make HWPLATFORM=X PRODUCT=Y" which then informs half a gazillion other symbols) -- and without a way to "seed" IntelliSense, many of my files end up gray because of file-scope #ifdef guards. |
@sean-mcmanus Right, I was ignorant. Had never really "seen" the 'defines' in c_cpp_properties... Was messing around with cpp.hint with little luck, hence the previous message. Pardon the noise. |
Yeah, if you want to get rid of the gray, you should set the defines appropriately. One side benefit is that it makes it easier to detect what code is getting skipped by IntelliSense due to incorrect defines. |
Hi, First, thank you for this awesome extension. Concerning this feature, I understand that it may be useful for many people, but I would love to see a setting that could disable it if wanted. Indeed, I use VSCode as my main editor, but I use IAR Workbench as embedded system programming/debugging platform. A lot of my defines are declared in the IAR Project file, and this feature greys almost all of my code. I am pretty sure that a lot of people could also be interested in turning this feature OFF too. (Maybe there is one, and I could not find it though) For reference and as temporary fix, I found that commenting out the following line in // this.languageClient.onNotification(InactiveRegionNotification, (e) => this.updateInactiveRegions(e)); Thanks again. |
@sean-mcmanus Hi, is there a way to disable this new function, like @eskild, many defined are passed by makefiles. Now almost all my code is grey. I'm not sure to understand the "defines" in the c_cpp_properties. There is no way I'm inputting all the defines there. Please, is there a way to turn this off or revert back to the last version of VS CODE.... Thanks ! P.S.: I'm a bit of a noob with vs code settings ... |
EDIT: As of v0.16.0, there exists a setting to disable inactive region colorization. Look at my post below for directions on how to change the settingHey @ArnaudNe. Your request is completely reasonable and we think there should be a way to turn off the setting as well. For now, your solution is the "correct" way to disable the feature. Keep in mind that future updates will rollback any changes to
I hope this helps. Let me know if any further clarification would be helpful. 😃 |
Thank you @grdowns for the complete solution 😊 |
Note the path for Windows is: |
With the new setting the extension should be able to revert back to the previous behavior when disabled, so |
In my case, I have a section of code inside an #ifdef xxx but it is defined: when I hover the variable it says "#define xxx 1". So I don't understand why it's not colored. |
@malafaya Is your intelliSenseEngine set to "Default"? By "not colored" do you mean "gray"? When you hover over a literal number, does it show something like (int)100? If not, then the intelliSense is falling back to the tag parser for the "xxx" variable so the variable might be not be visible to the intelliSense engine. It looks like when the intelliSenseEngine crashes, the inactive regions are not updated/reset, so that can cause stale gray text. |
@sean-mcmanus IntellisenseEngine is set to Default. Yes, sorry: "not colored" as in "gray". Hover a numeric literal shows nothings. |
@malafaya Something in the translation unit is crashing our intelliSense process causing it to fall back to the tag parser for hover, which is where the "#define xxx 1" is coming from (we fixed one common case causing 50% of the issues for our next release). You could try adding the macro to the "defines" list to make sure the intellisense sees it, but if it still crashes it might not update the coloring in time. If you're on Mac, you can find crash logs under |
Not fixed yet. Just updated and had to do (again) what @grdowns posted. Hopefully this will get fixed someday. |
Hey @ivsanro1, thanks for bumping this issue. We added a setting in v0.16.0 to turn this off from To disable the setting:
I'll edit my former post with a header so that people stumbling upon this thread don't get confused. Thanks again! |
@sean-mcmanus What is the correct way to set the defines appropriately? Now it's done via |
@rvanlaar It depends on how you're configuring IntelliSense. You could add the defines to c_cpp_properties.json or the setting C_Cpp.default.defines. If you use compileCommands or configurationProvider, then the defaults should come automatically from those. |
Thank you for your comments. I've configured the c_cpp_properties.json via the cpp plugin and generated a compile_commands.json via |
@rvanlaar Then if you have the compileCommands property set, the defines should get picked up from your compile_commands.json. Let us know if that isn't working for you. |
It works. |
Splitting this out from #230 and tagging it for the February release. This feature is achievable using VSCode's text decorations. We still need to investigate whether using text decorations is fast enough to color the whole file, so we won't be implementing all of the colorization features at once.
The text was updated successfully, but these errors were encountered: