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

Open
rokudone opened this issue Feb 3, 2024 · 2 comments
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!

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

2 participants