question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GoTo Definition for marked template type not working as expected

See original GitHub issue

In 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:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
HighCommander4commented, Mar 16, 2022

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 the t and >, it’s this cursor position that’s sent.

Clangd then needs to decide whether to use the > or the t 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.

0reactions
wangyu-commented, Aug 24, 2022

I have encountered similiar problems.

Thanks for @HighCommander4 's explanation, I have found the reason and known how to a workaround it.

Assuming you’ve selected the range BandList in the forward direction, such that your cursor is between the t and >, it’s this cursor position that’s sent.

Clangd then needs to decide whether to use the > or the t 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.

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 of BandList. For my case, the workaround is just to put the cursor in the middle of BandList and don’t double click.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found