GoTo Definition for marked template type not working as expected
See original GitHub issueIn the term std::optional<types::nr_rrc::BandList>
, I mark BandList
and hit Go to Definition.
I would expect that this jumps to types::nr_rrc::BandList
, but it jumps to std::optional
.
Do I miss something here?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Go to definition not working for template type parameter type
C++. Let's have a class template "template <typename T> class CT {};" and a "class CFoo {};". Then "class bar { CT<CFoo> blah;...
Read more >"Go To Definition" not working in VS2022 when editing ...
I have checked that the Keyboard assignment is correct, i.e., in VS2022 Options/Environment/Keyboard, [F12] is assigned to Edit.GoToDefinition.
Read more >Software Template Array Inputs Not Working As Expected #7090
This means that the array is being converted to a string somewhere under the hood, which results in arrays disappearing. Possible Solution. Fix ......
Read more >Solved: Template add function expect its first parament to...
Template add function expect its first parament to be integer or a decimal number, while the provided value is of type string; how...
Read more >Template type checking - Angular
Troubleshooting template errorslink · When a library's typings are wrong or incomplete (for example, missing null | undefined if the library was not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The Language Server Protocol currently only accepts a single position as input for the go-to-definition request, not a range.
Assuming you’ve selected the range
BandList
in the forward direction, such that your cursor is between thet
and>
, it’s this cursor position that’s sent.Clangd then needs to decide whether to use the
>
or thet
for targeting. It tries the character to the right of the cursor first, i.e. the>
, which is associated with the class template, so it navigates to the class template.I agree this behaviour is suboptimal. Hopefully, LSP can add support for sending the entire range in https://github.com/microsoft/language-server-protocol/issues/1029.
I have encountered similiar problems.
Thanks for @HighCommander4 's explanation, I have found the reason and known how to a workaround it.
For me, the “go to definition” doesn’t work correctly since I have a habit of double clicking on the
BandList
, then the cursor is automatically placed at the end ofBandList
. For my case, the workaround is just to put the cursor in the middle ofBandList
and don’t double click.