Support selectors with a trailing comma

This commit is contained in:
Kevin Sawicki
2013-08-06 15:55:50 -07:00
parent e61992c1f6
commit fe9ffbeb12
2 changed files with 7 additions and 2 deletions

View File

@@ -42,6 +42,8 @@ describe "TextMateScopeSelector", ->
expect(new TextMateScopeSelector('a,b,c').matches(['b', 'c'])).toBeTruthy()
expect(new TextMateScopeSelector('a, b, c').matches(['d', 'e'])).toBeFalsy()
expect(new TextMateScopeSelector('a, b, c').matches(['d', 'c.e'])).toBeTruthy()
expect(new TextMateScopeSelector('a,').matches(['a', 'c'])).toBeTruthy()
expect(new TextMateScopeSelector('a,').matches(['b', 'c'])).toBeFalsy()
it "matches groups", ->
expect(new TextMateScopeSelector('(a,b) | (c, d)').matches(['a'])).toBeTruthy()

View File

@@ -40,8 +40,11 @@ composite
/ expression
selector
= left:composite _ "," _ right:selector {
return new matchers.OrMatcher(left, right);
= left:composite _ "," _ right:selector? {
if (right)
return new matchers.OrMatcher(left, right);
else
return left;
}
/ composite