Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definition jumps are not possible with files containing Japanese characters. #1347

Closed
rokudone opened this issue Feb 3, 2024 · 5 comments
Closed
Labels
bug Something isn't working pinned This issue or pull request is pinned and won't be marked as stale

Comments

@rokudone
Copy link

rokudone commented Feb 3, 2024

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.

●-test rb-temp-WSL-Ubuntu-22 04_-Visual-Studio-Code-2024-02-03-20-28-01

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.

@rokudone rokudone added the bug Something isn't working label Feb 3, 2024
@vinistock
Copy link
Member

Thank you for the bug report!

I suspect this is related to #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.

@vinistock vinistock added the pinned This issue or pull request is pinned and won't be marked as stale label Feb 5, 2024
@rokudone
Copy link
Author

rokudone commented Feb 6, 2024

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!

@yamatowani
Copy link

I have a similar problem, How is your progress?

Description

I'm also using VSCode's ruby-lsp plugin, but it seems that if there is more than 13 bytes of character data, including multibyte characters, in the method comment, I cannot define a jump.
Specifically, it is not possible to jump from the followingfoobar instances to the definition source.

Case Data Quantity Result
"あああ" 9byte Success
"ああああ" 12byte Success
"ああああa" 13byte Failed
"あああああ" 15byte Failed

Success File

class Foo
  # ああああ
  def foobar
    puts 'foobar'
  end
end

foo = Foo.new
foo.foobar

Failed File

class Foo
  # あああああ
  def foobar
    puts 'foobar'
  end
end

foo = Foo.new
foo.foobar

environment

  • macOS Sonoma 14.4
  • ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin23]
  • About VSCode
    • Version: 1.93.1 (Universal)
    • Commit: 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
    • Date: 2024-09-11T17:20:05.685Z
    • Electron: 30.4.0
    • ElectronBuildId: 10073054
    • Chromium: 124.0.6367.243
    • Node.js: 20.15.1
    • V8: 12.4.254.20-electron.0
    • OS: Darwin arm64 23.4.0

@vinistock
Copy link
Member

We need to finalize #2051. I ended up not being able to dedicate enough time to help the author push the PR over the finish line. I'm going to ask to get the PR up again and help get it shipped.

@vinistock
Copy link
Member

Since this issue is a duplicate of #1251, I'm going to close this issue to centralize all discussions there. PR #2619 is about to fix this.

@vinistock vinistock closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pinned This issue or pull request is pinned and won't be marked as stale
Projects
None yet
Development

No branches or pull requests

3 participants