Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Safe Navigation operator (&.) should be an operator #167

@JustinAiken

Description

@JustinAiken

Support for this operator was added in #125, but I think it should be classified different:

  • punctuation.separator.method.ruby
    • (what it is now)
      puncuation
  • keyword.operator.logical.ruby

If there's an agreement, I'd be happy to open a PR that changes it along with the test

Activity

hediyi

hediyi commented on Sep 23, 2016

@hediyi
Contributor

I think "logical" is a bad scope name for &.:

  • although author&.posts is sort of used as a shorthand of author && author.posts, they're different in that it only skips the invocations on nil but not false
  • "logical" is shaky even for && for that it's essentially a flow control operator in Ruby (so as &.)
  • there's also a . part in it
bbugh

bbugh commented on Jul 11, 2019

@bbugh

Is there any way to make progress with this? I don't have syntax highlighting for safe navigation operators in VSCode which uses this language server. Considering this is a few years old, it would be nice!

jmoglesby

jmoglesby commented on Apr 4, 2021

@jmoglesby

This issue was addressed for the vscode-ruby library, but it still has not been addressed for the atom/language-ruby library.

Here was the vscode-ruby solution, which I believe is still using TextMate:

{
	"comment": "Safe navigation operator",
	"match": "(&\\.)\\s*(?![A-Z])",
	"captures": {
		"1": {
			"name": "keyword.operator.logical.ruby"
		}
	}
},

Can we get this applied to the Tree-sitter version for Atom, so that Safe Nav operators can be highlighted as operators, rather than as methods?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bbugh@JustinAiken@winstliu@hediyi@jmoglesby

        Issue actions

          Safe Navigation operator (&.) should be an operator · Issue #167 · atom/language-ruby