mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 07:58:04 +03:00
Support space-separated scopes in selector parser
This commit is contained in:
parent
3e5448b698
commit
beeaa01d22
@ -33,3 +33,9 @@ describe "TextMateScopeSelector", ->
|
||||
expect(new TextMateScopeSelector('(a,b) | (c, d)').matches(['c'])).toBeTruthy()
|
||||
expect(new TextMateScopeSelector('(a,b) | (c, d)').matches(['d'])).toBeTruthy()
|
||||
expect(new TextMateScopeSelector('(a,b) | (c, d)').matches(['e'])).toBeFalsy()
|
||||
|
||||
it "matches paths", ->
|
||||
expect(new TextMateScopeSelector('a b').matches(['a', 'b'])).toBeTruthy()
|
||||
expect(new TextMateScopeSelector('a b').matches(['b', 'a'])).toBeFalsy()
|
||||
expect(new TextMateScopeSelector('a c').matches(['a', 'b', 'c', 'd', 'e'])).toBeTruthy()
|
||||
expect(new TextMateScopeSelector('a b e').matches(['a', 'b', 'c', 'd', 'e'])).toBeTruthy()
|
||||
|
@ -39,8 +39,26 @@ scope
|
||||
}
|
||||
}
|
||||
|
||||
path
|
||||
= first:scope others:(_ scope)* {
|
||||
return function(scopes) {
|
||||
var scopeMatchers = [first];
|
||||
for (var i = 0; i < others.length; i++)
|
||||
scopeMatchers.push(others[i][1]);
|
||||
|
||||
var matcher = scopeMatchers.shift();
|
||||
for (var i = 0; i < scopes.length; i++) {
|
||||
if (matcher(scopes[i]))
|
||||
matcher = scopeMatchers.shift();
|
||||
if (!matcher)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
expression
|
||||
= scope
|
||||
= path
|
||||
|
||||
/ "(" _ selector:selector _ ")" {
|
||||
return selector;
|
||||
|
Loading…
Reference in New Issue
Block a user