Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Syntax highlighting issue with safe navigation operator #288

Closed
ob-stripe opened this issue Mar 10, 2018 · 9 comments
Closed

Syntax highlighting issue with safe navigation operator #288

ob-stripe opened this issue Mar 10, 2018 · 9 comments

Comments

@ob-stripe
Copy link

Your environment

  • vscode-ruby version: 0.17.0
  • Ruby version: 2.4.3
  • VS Code version: 1.21.0
  • Operating System: macOS 10.13.3
  • Hardware (optional): MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)

Expected behavior

When calling a method on a variable using the safe navigation operator (&.), the variable should be highlighted.

Actual behavior

The variable is not highlighted.

Steps to reproduce the problem

Trivial:
screen shot 2018-03-10 at 10 55 20 pm

@ob-stripe
Copy link
Author

In case this helps:

screen shot 2018-03-10 at 10 58 35 pm

screen shot 2018-03-10 at 10 58 44 pm

This issue might be related to / a dupe of #283.

@wingrunr21
Copy link
Collaborator

wingrunr21 commented Mar 10, 2018

I'm going to guess that it is but until I'm sure I'm going to leave this open.

I haven't gotten a chance to dive into this yet but my guess is the grammar doesn't have explicit support for that syntax given it is relatively new.

Edit: yep, atom/language-ruby#167 confirms there's an issue with the scope. I'll dig in from this angle first.

@orthodoX
Copy link

Confirmed, and it's quite annoying. Do we have any indications that this is going to be fixed any time soon?

@wingrunr21
Copy link
Collaborator

The indicator is the Atom issue linked above. Until semantic syntax highlighting lands in the language server protocol highlighting is based on coded grammars. As Atom is the upstream grammar for us, they need to fix so I can pull it in.

@bbugh
Copy link

bbugh commented Jul 11, 2019

According to this PR, they have support for the safe navigation operator since 2015: atom/language-ruby#125

Is there an easy way to enable it for this extension?

@wingrunr21
Copy link
Collaborator

@minkir014
Copy link

@wingrunr21 He added some lines in a coffee script file. Can this be the cause to this issue?

@bbugh
Copy link

bbugh commented Jul 12, 2019

The issue described in the original post is still present, though! My editor matches the screen shots. Variables using object&.something are not correctly colored.

@wingrunr21
Copy link
Collaborator

@minkir014 Potentially. VSCode activates grammars based on the detected language type at the bottom and whether that language declares other languages can be "embedded". If that parent language doesn't declare embedded languages then there's not much that can be done from a highlighting perspective.

@bbugh
The coloring is based on the matching scopes and whatever your theme has specified for those scopes. The grammar would need to change to the appropriate scope. You commented on the exact upstream issue for this: atom/language-ruby#167. You could open a PR against that repo to fix it and then I could pull it in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants