Sublime Forum

Go to definition for Ruby constants seem broken

#1

I’m not entirely sure if this ever worked, but using the dev build, Build 3175, go to definition for Ruby constants does not work.

Given a model, Post.

class Post
  SLUG_SEPARATOR = "-".freeze
end

Using Goto Definition on Post::SLUG_SEPARATOR does error out with the following message.

Unable to find SLUG_SEPARATOR

Further, Goto Symbol in Project does not seem to be able to find any Ruby constants as well.

Any light on the matter would be much appreciated.

0 Likes

#2

@wbond could you perhaps shed some light on the matter?

0 Likes

#3

I guess you’d want to modify https://github.com/sublimehq/Packages/blob/bde5c235ae4ec1db79d0bcc03f7fdd9424c063cf/Ruby/Symbols%20-%20Classes%20-%20Modules.tmPreferences#L5 to include entity.name.constant.ruby, if that’s how the constant is scoped.

1 Like

#4

I know it was written more than a year ago but it helped me. Weird it is not yet fixed in the recent Sublime update.
I’m new to this forum. Do you have any idea how make this fix to be added into the main code branch?

0 Likes

#5

It is not fixed as it is no bug. According to the history of Ruby constants have never been part of the symbol index out of the box.

It’s always a question of taste to decide how much to add to the index. Adding too much may also cause too much noise.

You don’t need to manipulate the existing symbol definition, but easily extend the default behavior by writing your own symbol definition.

Packages/User/Ruby/Symbols - Constants.tmPreferences

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <key>scope</key>
    <string>source.ruby entity.name.constant</string>
    <key>settings</key>
    <dict>
        <key>showInSymbolList</key>
        <integer>1</integer>
        <key>showInIndexedSymbolList</key>
        <integer>1</integer>
    </dict>
</dict>
</plist>

Nevertheless, any kind of improvement to the default syntaxes is very welcome. You’ll find the repo of ST’s builtin syntax packages at https://github.com/sublimehq/Packages. It is the place to discuss issues, ideas and propose changes.

Development of ST’s default syntaxes takes place as an Open Source approach mainly driven by the community. The final review and decision is up to @wbond (or any other core developer) then.

0 Likes