Skip to content

Commit 1dad088

Browse files
Change while/until and if/unless block rules so it could match inside different parenthesis and after the comma. Add additional capture group in the modifiers rules, because i didn't find another way to assign multiple scope names inside one rule. Fix test file.
1 parent 2f1e1e8 commit 1dad088

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

Syntaxes/Ruby.plist

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@
569569
<key>contentName</key>
570570
<string>string.regexp.classic.ruby</string>
571571
<key>end</key>
572-
<string>((/[eimnosux]*))\s*(?:(\b(?:if|unless)\b(?![?!]))|(\b(?:while|until)\b(?![?!])))?</string>
572+
<string>((/[eimnosux]*))\s*(?:((\b(?:if|unless)\b(?![?!])))|((\b(?:while|until)\b(?![?!]))))?</string>
573573
<key>endCaptures</key>
574574
<dict>
575575
<key>1</key>
@@ -585,12 +585,22 @@
585585
<key>3</key>
586586
<dict>
587587
<key>name</key>
588-
<string>meta.control.modifier keyword.control.if-unless.ruby</string>
588+
<string>meta.control.modifier</string>
589589
</dict>
590590
<key>4</key>
591591
<dict>
592592
<key>name</key>
593-
<string>meta.control.modifier keyword.control.while-until.ruby</string>
593+
<string>keyword.control.if-unless.ruby</string>
594+
</dict>
595+
<key>5</key>
596+
<dict>
597+
<key>name</key>
598+
<string>meta.control.modifier</string>
599+
</dict>
600+
<key>6</key>
601+
<dict>
602+
<key>name</key>
603+
<string>keyword.control.while-until.ruby</string>
594604
</dict>
595605
</dict>
596606
<key>patterns</key>
@@ -607,7 +617,12 @@
607617
<key>1</key>
608618
<dict>
609619
<key>name</key>
610-
<string>meta.control.modifier keyword.control.if-unless.ruby</string>
620+
<string>meta.control.modifier</string>
621+
</dict>
622+
<key>2</key>
623+
<dict>
624+
<key>name</key>
625+
<string>keyword.control.if-unless.ruby</string>
611626
</dict>
612627
</dict>
613628
<key>match</key>
@@ -627,14 +642,14 @@
627642
\Win|^in|
628643
\W!|^!|
629644
\W\?|^\?)
630-
\s*\b(if|unless)\b(?![?!])
645+
\s*\b((if|unless))\b(?![?!])
631646
</string>
632647
</dict>
633648
<dict>
634649
<key>begin</key>
635650
<string>(?x)
636651
(?&lt;!::)
637-
(?&lt;=&lt;|&amp;|\||=|&gt;|~|\^|[+\-*/%]|\.{2}|\.{3}|^|;|:|
652+
(?&lt;=&lt;|&amp;|\||=|&gt;|~|\^|[+\-*/%]|\.{2}|\.{3}|^|;|:|\[|\(|\{|,|
638653
\Wif|^if| # \WX|^X is equivalent to \bX
639654
\Wunless|^unless| # this is workaround for code editors which doesn't support onigomo
640655
\Wcase|^case| # https://github.com/microsoft/vscode-textmate/issues/121#issuecomment-565689295
@@ -680,6 +695,19 @@
680695
</array>
681696
</dict>
682697
<dict>
698+
<key>captures</key>
699+
<dict>
700+
<key>1</key>
701+
<dict>
702+
<key>name</key>
703+
<string>meta.control.modifier</string>
704+
</dict>
705+
<key>2</key>
706+
<dict>
707+
<key>name</key>
708+
<string>keyword.control.while-until.ruby</string>
709+
</dict>
710+
</dict>
683711
<key>match</key>
684712
<string>(?x)
685713
(?&lt;=[}\])\w?!"'`])
@@ -697,16 +725,14 @@
697725
\Win|^in|
698726
\W!|^!|
699727
\W\?|^\?)
700-
\s*\b(while|until)\b(?![?!])
728+
\s*\b((while|until))\b(?![?!])
701729
</string>
702-
<key>name</key>
703-
<string>meta.control.modifier keyword.control.while-until.ruby</string>
704730
</dict>
705731
<dict>
706732
<key>begin</key>
707733
<string>(?x)
708734
(?&lt;!::)
709-
(?&lt;=&lt;|&amp;|\||=|&gt;|~|\^|[+\-*/%]|\.{2}|\.{3}|^|;|:|
735+
(?&lt;=&lt;|&amp;|\||=|&gt;|~|\^|[+\-*/%]|\.{2}|\.{3}|^|;|:|\[|\(|\{|,|
710736
\Wif|^if| # \WX|^X is equivalent to \bX
711737
\Wunless|^unless| # this is workaround for code editors which doesn't support onigomo
712738
\Wcase|^case| # https://github.com/microsoft/vscode-textmate/issues/121#issuecomment-565689295

Tests/end_distinction.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# singleline
66
class Foo; @@a = 1; end
7-
class Foo::Bar << M::Baz; @@a = 1; end
7+
class Foo::Bar < M::Baz; @@a = 1; end
88

99
# multiline
1010
class Foo

0 commit comments

Comments
 (0)