-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Go to references on TS function erroneously includes the definition #114673
Comments
(Experimental duplicate detection)
|
Related to microsoft/TypeScript#42889 |
I read the linked issue. Forgive the silly question, but is it possible to perform the filtering on the vscode side, at least for common cases? Or is it not so easy to identify whether references returned by the language server are actually at the current location? |
+1, also having this issue. Is there a way of fixing it temporarily? |
Reading over this issue again, I think this is actually the expected behavior but agree it is a bit confusing if you think about it too much When you press F12 on a symbol you usually want a list of every place that symbol is used anywhere in the codebase (this is the only way to get this information). This matches what Visual Studio does in my testing: The references code lens however excludes definitions because, in this context, you really only care about references to the symbol itself and not the location(s) where it is defined. It would be confusing if definitions increased the references code lens count I think ideally we'd allow filtering down the Closing this in favor of that issue since I think the current behavior is working as expected |
I opened the issue and I do not believe that it is working as expected. When I click on a function definition and ask for the references to that function, I do not expect to find the definition of the function I clicked on. That's not a reference to the function, that's the function itself! The issue you linked does not capture this context and to be honest I don't understand it or its relevance. It being open gives me no confidence that the issue I found might be addressed. To reiterate my earlier question, could some filtering of the results occur on the vscode side when clicking the 'go to references' menu item on a definition? Does this already happen with the code lens thing? |
Issue Type: Bug
If a typescript function is used more than once, then the Go To References function erroneously shows the definition of the function itself as an additional reference. So a function used 2 times appears to have 3 references.
This interacts badly with the setting to "goto" rather than "peek" references because the definition seems to be the first reference, therefore you go nowhere. It is still annoying when peeking, because the first reference shown is the definition (which is where you already are), and it takes some clicking to get to the actual usages.
The problem also occurs for arrow functions assigned to variables.
The problem does not occur when using codelens, and codelens peek correctly shows only the actual references.
VS Code version: Code 1.52.1 (ea3859d, 2020-12-16T16:34:46.910Z)
OS version: Windows_NT x64 10.0.19042
The text was updated successfully, but these errors were encountered: