vscode-cpptools
vscode-cpptools copied to clipboard
Add menu popup for enabling/disabling define
Feature Request
Consider following:
#if SOMETHING /* some code */ #ENDIF
I'd like to be able to change how SOMETHING is defined for purpose of Intellisense parsing via right-click menu. This menu should have following entries:
Enable define (set to 1) Disable define (set to 0) Set value Current value: ...
(the last one allows to set specific value)
Each option should should change "defines" in c_cpp_properties.json accordingly, and trigger Intellisense.
@AdamKlob I don't think VS Code allows the context menu to be updated based on the cursor context, but it might be possible to add a code action on the #if SOMETHING with the menu items. Another issue is that adding to defines in c_cpp_properties.json won't have any effect if the user is configured with compile_commands.json or a configurationProvider, so to support those scenarios we might need some new property like additionalDefines that always get added or the feature may seem to not work (or we could disable it in those cases).
"Rename symbol" is able to act based on cursor context.
The exact mechanism (which configuration file is modified) is not really relevant. I knew about c_cpp_properties.json, that's why i singled it out. Any other file is fine.
@AdamKlob Yes, we can react to the cursor context after the command is used but as far as I know "Rename symbol" always appears in the menu context and isn't dynamic based on the cursor, so the Add define feature would have to always appear in the right-click menu. The c_cpp_properties.json is the file that would be used, but the "defines" are not currently checked/used if configurationProvider or compileCommands are set, so there would need to be some way to handle that if this were to be implemented.
This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.