Feature Request: open Peek References when Ctrl-click is on the symbol in its declaration
inliquid opened this issue · 15 comments
Initially this issue was opened in vscode-go extension repo: microsoft/vscode-go#2451
Maintainer (@ramya-rao-a) asked to reopen it here.
By default, with Ctrl-click
you go to symbol definition, f.e. to a function declaration. When you make Ctrl-click
on a declared name, VS Code in fact does nothing, which seems counter-intuitive. In most of the cases I need to Shift-F12
to see the usages of that symbol or if I want to go back from that place after some navigation happened around that symbol.
I think it would be very useful, if when you Ctrl-click
on a function, variable, or a type name in a place where the symbol is defined, VS Code
will open a Peek References of that symbol. This would be close to what Goland does by default and what I personally found extremely helpful.
Translating the above in terms of providers:
When a definition provider returns the same location as the word on which the cursor is, trigger
Peek References
command
We find this feature very confusing. Can we have a conversation about it before it ships in stable?
C++ find all references is (potentially) very expensive to compute and it's counter-intuitive to invoke feature B when you ask for feature A. Can you expose the ability to invoke find all references via goto definition some other way? I think a lot of people are going to be confused by this behavior.
Well, users have asked for it and it's when other editors, like IntelliJ, do. For instance, this is a nice comparison from the perspective of a power user: https://gist.github.com/joeytwiddle/49ecf347bf97c5a67a8d713dd437efcf#go-to-defintionreferences
We find this feature very confusing. Can we have a conversation about it before it ships in stable?
I am unsure if you say this as a user or as the owner of a slow references provider? For C++ or for slow providers in general I feel it needs some way to allow them to express that they are slow. TBH even today peek references doesn't work well for slow providers and either per provider or per request a way to say "this will take a while" might be needed. In that case the UX can adapt and for instance not offer such rapid code navigation features.
This was reported to me as counter intuitive by my team members and I agreed with them. The potential slowness of find all references for C++ is just an additional disadvantage that we are sensitive about and I probably shouldn't have mentioned it.
Just to be clear, I'm not saying you shouldn't ever have this feature because clearly there are a few people who want it. But the number of upvotes here doesn't seem to make the case that this is a universally desired feature so perhaps a setting should exist to control the behavior or a new key binding should be added. Users are accustomed to CTL+click and F12 doing a goto definition operation. Having that spuriously change to find all references depending on the context creates uncertainty for the user.
Another idea I just had while typing this... What if hover (or CTL+hover) was improved to add a hyperlink that links to the command to find all references? The fixit experience for problems provides a UI paradigm that could be reused for this:
Instead of "Peek Problem" or "Quick Fix", links could be added for "Find References" or "Peek References". In this case the developer knows exactly which language feature will execute. And the cost in clicks to invoke this feature can equal that of WebStorm.
desired feature so perhaps a setting should exist to control the behavior or a new key binding should be added.
Sure, we can always add a way to enable/disable this and in fact insiders is the vehicle to collect such feedback. Yours and your team's feedback has now been noted and see what else comes in. Note that we have also received positive feedback. Still, adding a new feature and disabling it by default is almost like not adding a new feature and assuming we have a setting to control, it will likely be on by default.
Note that we have also received positive feedback
Again, I'm not trying to contest that this feature is bad or confusing for everyone. I don't think we have enough data at this point to make a call about the majority opinion though (and maybe we won't until after it ships in stable).
I suggested an alternate implementation that has zero chance of confusion but I didn't hear your thoughts on that proposal. If the goal is quick access to additional language server commands, then making those commands easily available in the hover UI would address that need without introducing confusion for users who have been using F12 for years.
I suggested an alternate implementation that has zero chance of confusion but I didn't hear your thoughts on that proposal.
I did ping you on a partner issue where this was already suggested. In fact Java is doing something very similar already today and we could make it a thing. Having said that, I don't think they are mutually exclusive - I actually want both
Seems that in JavaScript files, imports with a proper definition (from source file or .d.ts) are considered as "references", but ones without are "declarations".
So now when I press F12 on those imports, some of them will jump to their declarations but others will peek all references. It's super confusing and super annoying and I consider this as a bug.
is there a way to turn off this feature please ? this gives pretty horrible experience with C/C++
Yeah, we would like some way we could disable it for our C/C++ extension.
I'm wondering, why do you guys ever Ctrl-click
(or press F12
) when you are at definition of smth, if you don't want IDE to find anything about this definition?
@inliquid Users might not notice they're at the definition already (i.e. they may mistake the code for a C++ declaration or vice versa) or they might expect to go to the declaration instead. Maybe users will stop doing that once they realize it invokes Find All References?
@inliquid Users might not notice they're at the definition already (i.e. they may mistake the code for a C++ declaration or vice versa)
We can think about adding a setting which defines the fallback command, e.g. goto declaration for cpp from definitions or simply nothing
fyi - I have pushed a commit that adds settings like editor.gotoLocation.alternativeDefinitionCommand
etc. They allow to define what happens when the corresponding go-to-command navigates to the current location, e.g @sean-mcmanus could make definition and declaration be "counter parts" so that go to definition on a definition goes to the declaration and the other way around