Sublime Forum

New "References" mouse hover is nice. Make a bindable command to browse them?

#1

Build 3146 introduced:

Added Goto References when hovering over a symbol

Making it so that when you mouse-hover over an identifier/symbol, not only are you shown the location of its definition, but now also the locations where it has been referenced/used.

That’s cool, but only being able to get at this new information using a mouse-hover limits its usefulness. The long-standing “Definition” feature has a keybinding (F12) in addition to its presence in the mouse-hover, so how about a matching keybinding (Shift+F12?) for the new References feature?

i.e. when the keyboard cursor is on an identifier/symbol, pressing Shift-F12 shows a Find Results panel populated with the same Reference locations as would be shown in the mouse-hover.

0 Likes

#2

Did I explain this well? Do you reading get what I mean?

0 Likes

#3

I understand what you are asking for :slight_smile:
currently the implementation in Packages/Default/symbol.py doesn’t have a command associated with it (which would enable one to create a keybinding themselves), but one could build a plugin for this if desired

1 Like

#4

Imo it should open a quick panel with the references because that supports keyboard navigation, much like what happens when you invoke “go to symbol” via F12.

2 Likes

#5

Oh yeah, when a symbol’s Definition site is ambiguous, goto_definition shows that panel.

I agree - that same type of panel would be great for a keyboard driven way to browse the References.

0 Likes

#6

Sublime HQ have implemented “Goto Reference…” and “goto_reference” in build 3152.

They are beautiful people! :sun_with_face:

0 Likes

#7

I agree they are beautiful.

Sadly for me, I cannot for the life of me get anything to happen when I select Goto Reference… from the menu.

If I am on the definition of a function, should calling Goto Reference… allow me to see the places that are calling that function? Right now nothing happens.

0 Likes

#8

what languages/syntaxes have you tried this in? it works fine for me in C# and Python, for example. Perhaps you have overridden Packages/Default/symbol.py where this functionality is implemented?

0 Likes

#9

Only tokens that are classified as certain scopes are considered References. It’s not enough for the token to simply be present. I don’t think the rules are documented yet.

0 Likes

#10

Um - I am using ruby. I would think that would work as the definitions and references are both pretty clear.

0 Likes

#11

Put the text cursor on a reference to a function, then select Tools > Developer > Show-Scope-Name from Sublime’s menu bar. As I understand it, it’s about these scope(s) not meeting Sublime’s internal rules for what’s considered a Reference.

0 Likes

#12

17 bytes: source.ruby.rails meta.controller.rails meta.function.ruby entity.name.function.ruby

So that is the function definition.

And here’s the reference

3280 bytes: source.ruby.rails meta.controller.rails

LOL - is that it right there?

0 Likes

#13

No, it looks like ruby needs an update to properly scope references.

0 Likes

#14

So you’re agreeing with me that that is the problem? I realize it was sort of ambiguous the way I said it.

0 Likes

#15

The issue is that the current version of the Ruby syntax doesn’t follow the scope naming guidelines, so the way that Show References is implemented doesn’t know that it is a reference.

Part of the issue, I am almost certain, is that Ruby is so flexible that lots of syntax ambiguous. If you see a single identifier it could be returning a variable, or returning an attr, or calling a function and returning the return value from that. Or just calling a function.

For References to work in Ruby, we’d have to be over-zealous and produce a lot of false positives to catch the real references also.

1 Like