microsoft / microsoft/vscode-cpptools
Add a command "Go To Definition/Declaration "
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Feature Request
I would love to be able to apply "Go To Declaration" when I am requesting it on a definition, and "Go To Definition" when I am requesting it on a declaration.
I foolishly thought this was the standard F12 behaviour before finding out I need to bind both and use them contextually! I imagine its trivial to implement the context switching internally and apply the correct one given the context of the request.
i.e.
IF requested on a declaration -> Go To Definition
IF requested on a definition -> Go To Decleration
My workaround currently is binding the behaviour to the "when" field inside Keybinds.json based on file endings:
{
"key": "F12",
"command": "editor.action.revealDeclaration",
"when": "editorHasDeclarationProvider && editorTextFocus && !isInEmbeddedEditor && resourceExtname =~ /\\.(cpp|cxx|cc|c\\+\\+|c)$/"
},
{
"key": "F12",
"command": "editor.action.revealDefinition",
"when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor && resourceExtname =~ /\\.(hpp|hxx|hh|h\\+\\+|h|inl|ipp)$/"
},
This fails in nuanced cases such as F12 on #include lines when in a source file, this will attempt "Go To Declaration" and fail but should be using "Go To Definition". Another reason a context based command would be useful!
A native command provided by the extension would be nice.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the existing editor.action.revealDeclaration and editor.action.revealDefinition commands and the F12/keybinding examples in the issue. Trace the C/C++ extension's command entry points and determine how the current symbol context, including #include lines, selects the target; done means one native command consistently chooses the appropriate action.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100