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

feat: update regex to only apply to symbols #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Kosai106
Copy link
Owner

@Kosai106 Kosai106 commented Jan 6, 2020

Re: #4

@@ -10,7 +10,7 @@ exports.activate = function(context) {
const document = editor.document;

if (editor && document.languageId === "ruby" || document.languageId === "haml" || document.languageId === "erb") {
const pattern = /:?(["|']?(\w[^\w\s]?)+["|']?)+\s*?=>\s*/g
const pattern = /[\d|:((\w[^\w\s]?))]+\s*?=>\s*/g
Copy link

@patbl patbl Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I paste it into a JavaScript console, I get a syntax error:

/[\d|:((\w[^\w\s]?))]+\s*?=>\s*/g
VM270:1 Uncaught SyntaxError: Invalid regular expression: /[\d|:((\w[^\w\s]?))]+\s*?=>\s*/: Unmatched ')'
    at <anonymous>:1:1

Also, the Ruby code in your example here is syntactically invalid, since you can't use numbers as keys in Ruby hashes with the colon syntax:

[1] pry(main)> { 1: :lol }
SyntaxError: unexpected ':', expecting =>
{ 1: :lol }

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll admit I've not used Ruby for almost two years now, but the syntax I'm using in my examples all worked fine when I was testing, which is why I'm confused by all of this.

I'll gladly accept contributions if you have a better solution in mind.

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

Successfully merging this pull request may close these issues.

2 participants