Definition jumps are not possible with files containing Japanese characters.
Ruby version
3.1.4, 3.2.2, 3.3.0
Code snippet
Gemfile
# frozen_string_literal: true
source 'https://rubygems.org'
ruby '3.3.0'
gem 'debug', platforms: %i[mri windows]
gem 'rubocop'
gem 'ruby-lsp'
vscode/settings.json
{
"[ruby]": {
"editor.defaultFormatter": "Shopify.ruby-lsp",
"editor.formatOnSave": true,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.semanticHighlighting.enabled": true,
"editor.formatOnType": true
},
"rubyLsp.rubyVersionManager": "rbenv",
"rubyLsp.formatter": "rubocop",
"rubyLsp.enabledFeatures": {
"codeActions": true,
"diagnostics": true,
"documentHighlights": true,
"documentLink": true,
"documentSymbols": true,
"foldingRanges": true,
"formatting": true,
"hover": true,
"inlayHint": true,
"onTypeFormatting": true,
"selectionRanges": true,
"semanticHighlighting": true,
"completion": true,
"codeLens": true,
"definition": true,
"workspaceSymbol": true,
"signatureHelp": true
}
}
success file
# frozen_string_literal: true
# Test Class
class Test
TEST = 'test'
def method1
# test
pp TEST
end
end
failed file
# frozen_string_literal: true
# Test Class
class Test
TEST = 'test'
def method1
# テスト
pp TEST
end
end
success file 2
# frozen_string_literal: true
# Test Class
class Test
TEST = 'test'
def method1
pp TEST
# テスト
end
end
VSCode
Version: 1.86.0 (user setup)
Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
Date: 2024-01-31T10:28:19.990Z
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Windows_NT x64 10.0.22621
However, I have the same issue on my Mac
Description
I was going to use vscode's ruby-lsp plugin. However, after struggling for a while, I could not make the definition jump. The cause seems to be the presence of Japanese comments in the file.
In the attached Ruby code, I assume a situation like jumping from pp TEST to TEST = 'test'.' In the case of the code written in success file 1', it succeeds. But for the code in failed file, it fails. The only difference is that the Japanese comment # テスト` is on the line above the jump source.
Furthermore, if you look at success file 2, it succeeds if the same Japanese comment is added to the line below the jump source.
If there is any information I am missing, please let me know.
Expected output
Maybe this is true for other languages as well. I hope that eventually Japanese will be handled properly and we can jump from pp TEST to TEST = 'test' in examples like failed file.
Thank you for the bug report!
I suspect this is related to https://github.com/Shopify/ruby-lsp/issues/1251. The Prism parser returns byte instead of character locations, so multibyte characters are currently throwing off the language server. We need to come up with a strategy to fix this generally for the entire language server since locations are used everywhere.
Thanks for getting back to me. I could not find that Issue. Sorry to have bothered you.
It seems like a difficult issue to solve. I will wait patiently. I look forward to having a great product available again. I wish you the best of luck!