ty icon indicating copy to clipboard operation
ty copied to clipboard

find-references on a definition should be find-uses (not include self)

Open Gankra opened this issue 2 months ago • 5 comments

Summary

x = 1
print(x)

If you find-references on the second x it goes to the first (good!) If you find-references on the first x it shows both itself and the second (bad, not helpful, should only be the second).

Version

No response

Gankra avatar Dec 16 '25 18:12 Gankra

Oh wild we actually support this distinction but it's something the client tells us which it wants?

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#referenceContext

Gankra avatar Dec 16 '25 18:12 Gankra

This problem affects PyCharm, where the default find usages shortcut doesn't work, but "find usages" from the menu does, which then shows two options, the current line and column as well sa the real find usages dialog the user wants.

konstin avatar Dec 16 '25 18:12 konstin

If you find-references on the first x it shows both itself and the second (bad, not helpful, should only be the second).

This is also what pylance and rust analyzer does. So I'm not sure if this is indeed entirely undesired.

MichaReiser avatar Dec 16 '25 18:12 MichaReiser

Same if you do find references on a function, r-a returns the function as well as all uses.

MichaReiser avatar Dec 16 '25 18:12 MichaReiser

Hmm is cmd+click a different API than "find-references"? Or maybe it's one of those "they query a bunch of different ones with fallback" situtations?

Gankra avatar Dec 16 '25 19:12 Gankra