diff --git a/spec/app/text-mate-scope-selector-spec.coffee b/spec/app/text-mate-scope-selector-spec.coffee index 0bb111a42..708424ff1 100644 --- a/spec/app/text-mate-scope-selector-spec.coffee +++ b/spec/app/text-mate-scope-selector-spec.coffee @@ -13,6 +13,8 @@ describe "TextMateScopeSelector", -> expect(new TextMateScopeSelector('a').matches(['a.b'])).toBeTruthy() expect(new TextMateScopeSelector('a.b').matches(['a.b.c'])).toBeTruthy() expect(new TextMateScopeSelector('a').matches(['abc'])).toBeFalsy() + expect(new TextMateScopeSelector('a.b-c').matches(['a.b-c.d'])).toBeTruthy() + expect(new TextMateScopeSelector('a.b').matches(['a.b-d'])).toBeFalsy() it "matches disjunction", -> expect(new TextMateScopeSelector('a | b').matches(['b'])).toBeTruthy() @@ -22,6 +24,9 @@ describe "TextMateScopeSelector", -> it "matches negation", -> expect(new TextMateScopeSelector('a - c').matches(['a', 'b'])).toBeTruthy() expect(new TextMateScopeSelector('a-b').matches(['a', 'b'])).toBeFalsy() + expect(new TextMateScopeSelector('a -b').matches(['a', 'b'])).toBeFalsy() + expect(new TextMateScopeSelector('a -c').matches(['a', 'b'])).toBeTruthy() + expect(new TextMateScopeSelector('a-c').matches(['a', 'b'])).toBeFalsy() it "matches conjunction", -> expect(new TextMateScopeSelector('a & b').matches(['b', 'a'])).toBeTruthy() diff --git a/src/app/text-mate-scope-selector-matchers.coffee b/src/app/text-mate-scope-selector-matchers.coffee index 67b5310ab..062bc93fc 100644 --- a/src/app/text-mate-scope-selector-matchers.coffee +++ b/src/app/text-mate-scope-selector-matchers.coffee @@ -1,8 +1,10 @@ +_ = require 'underscore' + ### Internal ### class SegmentMatcher constructor: (segment) -> - @segment = segment.join('') + @segment = _.flatten(segment).join('') matches: (scope) -> scope is @segment diff --git a/src/app/text-mate-scope-selector-pattern.pegjs b/src/app/text-mate-scope-selector-pattern.pegjs index 7327cf876..e1dedb1c4 100644 --- a/src/app/text-mate-scope-selector-pattern.pegjs +++ b/src/app/text-mate-scope-selector-pattern.pegjs @@ -7,7 +7,7 @@ start = _ selector:(selector) _ { } segment - = _ segment:[a-zA-Z0-9]+ _ { + = _ segment:([a-zA-Z0-9]+[a-zA-Z0-9-]*) _ { return new matchers.SegmentMatcher(segment); }