language-ruby icon indicating copy to clipboard operation
language-ruby copied to clipboard

Regexp starting with = doesn't get highlighted.

Open envygeeks opened this issue 11 years ago • 7 comments

When doing the regexp:

/=\Z/

it doesn't get highlighted. It seems to only happen with =

envygeeks avatar Oct 16 '14 23:10 envygeeks

It gets highlighted if you write:

/\=\Z/

But I think both are the same valid regular expression.

nokutu avatar Apr 20 '15 14:04 nokutu

Ugh, this is annoying:

{
    'comment': 'Needs higher precidence than regular expressions.'
    'match': '(?<!\\()/='
    'name': 'keyword.operator.assignment.augmented.ruby'
}

No more easy fix :(

@envygeeks @nokutu do you two have any ideas about how to differentiate between /= and a regular expression starting with /=?

winstliu avatar Dec 02 '15 02:12 winstliu

/= is not valid Ruby, from what I gander it's trying to test for []=( as in:

def []=(key, val)
  $stdout.puts key, val
end

envygeeks avatar Dec 02 '15 02:12 envygeeks

Well... supposed to be trying to match it, I don't know why the / is there. Seems like a bug to me.

envygeeks avatar Dec 02 '15 02:12 envygeeks

Since the scope is keyword.operator.assignment.augmented I believe it is actually trying to match /= (an "augmented" operator that assigns something).

~~If it's not valid though...hopefully should be a simple deletion!~~

EDIT: Just did some quick googling and it looks like /= is valid after all: something like 6 /= 3 should work.

winstliu avatar Dec 02 '15 02:12 winstliu

@50Wliu you're right, I forgot about that since like literally nobody ever uses it, actually needs to be a var so you'll have to do something like x = 120; x /= 12 It's for assigning the result of the division. You can actually do it with all Maths operators: **=, *=, /=, +=, -=

envygeeks avatar Dec 02 '15 02:12 envygeeks

Actually needs to be a var

I should probably rephrase, it needs to have a setter.

envygeeks avatar Dec 02 '15 02:12 envygeeks