You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Go-to definition for singleton methods defined via class << self #3050
Thank you for the report! We do support that already and I can't reproduce with the example you mentioned. You can verify it in the LSP's codebase too, if you add Addon.load_addons to any file, you can jump to the definition of load_addons and land on the right place.
Those two PRs were closed, but we ended up implementing singleton support in different ones.
I suspect that the problem may be that one of the files in question is being excluded from indexing. Are these test files by any chance? Do you any configuration for indexing?
Note that our defaults exclude test directories from indexing and development gems too.
Hmm, I've opened the LSP's codebase in vscode and opened the dev container to confirm.
A strange issue I see is that if I hit the keybinding for going to definition when at the end of a word, it doesn't work, but if I'm within the word, then it does work:
ruby-lsp-demo.mov
I've now confirmed in my own codebase that go-to definition works the same, however I've noticed an additional issue: if I have a module that's defined like so:
moduleFoo::Barclass << selfdefbaz;endendend
Then if I try to jump to definition for Foo::Bar.baz, it won't work. On the other hand if the module is structured like so:
Thank you for the extra details, that's helpful. Not finding the method inside compact namespaces is an indexing bug, which will be fixed by #3062.
Concerning going to definition in the end of the word, I'll need to do a bit more research to understand what other language servers are doing. When your cursor is at the end of the word, it's position is actually one character after the word, which is why we don't find any targets.
But checking the behaviour on TypeScript, you can indeed jump to definition even if the position is off by one. Maybe the expected implementation is that the server will check if there's any content under the position and if not adjust the position by minus one? I'll need to understand this better.
Activity
vinistock commentedon Jan 13, 2025
Thank you for the report! We do support that already and I can't reproduce with the example you mentioned. You can verify it in the LSP's codebase too, if you add
Addon.load_addonsto any file, you can jump to the definition ofload_addonsand land on the right place.Those two PRs were closed, but we ended up implementing singleton support in different ones.
I suspect that the problem may be that one of the files in question is being excluded from indexing. Are these test files by any chance? Do you any configuration for indexing?
Note that our defaults exclude test directories from indexing and development gems too.
jesseduffield commentedon Jan 14, 2025
Hmm, I've opened the LSP's codebase in vscode and opened the dev container to confirm.
A strange issue I see is that if I hit the keybinding for going to definition when at the end of a word, it doesn't work, but if I'm within the word, then it does work:
ruby-lsp-demo.mov
I've now confirmed in my own codebase that go-to definition works the same, however I've noticed an additional issue: if I have a module that's defined like so:
Then if I try to jump to definition for
Foo::Bar.baz, it won't work. On the other hand if the module is structured like so:It will.
I believe the former syntax is now the preferred approach in rails applications, and I use that approach in my codebase.
vinistock commentedon Jan 14, 2025
Thank you for the extra details, that's helpful. Not finding the method inside compact namespaces is an indexing bug, which will be fixed by #3062.
Concerning going to definition in the end of the word, I'll need to do a bit more research to understand what other language servers are doing. When your cursor is at the end of the word, it's position is actually one character after the word, which is why we don't find any targets.
But checking the behaviour on TypeScript, you can indeed jump to definition even if the position is off by one. Maybe the expected implementation is that the server will check if there's any content under the position and if not adjust the position by minus one? I'll need to understand this better.
Fix singleton indexing under compact namespaces (#3062)
github-actions commentedon Mar 16, 2025
This issue is being marked as stale because there was no activity in the last 2 months
vinistock commentedon Mar 17, 2025
Since part of this issue has already been addressed, I created a separate one for the cursor position issue.