Skip to content

Commit

Permalink
Fix issue in scopeToLanguage (#14136)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Oct 24, 2016
1 parent 3cc0817 commit eea2028
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/vs/editor/node/textMate/TMSyntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ export class TMScopeRegistry {
// no scopes registered
return null;
}
this._cachedScopesRegex = new RegExp(`^((${escapedScopes.join(')|(')}))`, '');
escapedScopes.sort();
escapedScopes.reverse();
this._cachedScopesRegex = new RegExp(`^((${escapedScopes.join(')|(')}))($|\\.)`, '');
}
return this._cachedScopesRegex;
}
Expand Down
4 changes: 4 additions & 0 deletions src/vs/editor/test/node/textMate/TMSyntax.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ suite('TextMate.TMScopeRegistry', () => {
assert.equal(manager.scopeToLanguage('source.html'), null);

manager.register('html', 'source.html', null);
manager.register('c', 'source.c', null);
manager.register('css', 'source.css', null);
manager.register('javascript', 'source.js', null);
manager.register('python', 'source.python', null);
Expand All @@ -46,6 +47,7 @@ suite('TextMate.TMScopeRegistry', () => {
// exact matches
assert.equal(manager.scopeToLanguage('source.html'), 'html');
assert.equal(manager.scopeToLanguage('source.css'), 'css');
assert.equal(manager.scopeToLanguage('source.c'), 'c');
assert.equal(manager.scopeToLanguage('source.js'), 'javascript');
assert.equal(manager.scopeToLanguage('source.python'), 'python');
assert.equal(manager.scopeToLanguage('source.smarty'), 'smarty');
Expand All @@ -58,10 +60,12 @@ suite('TextMate.TMScopeRegistry', () => {

// misses
assert.equal(manager.scopeToLanguage('source.ts'), null);
assert.equal(manager.scopeToLanguage('source.csss'), null);
assert.equal(manager.scopeToLanguage('source.baz'), null);
assert.equal(manager.scopeToLanguage('asource.css'), null);
assert.equal(manager.scopeToLanguage('a.source.css'), null);
assert.equal(manager.scopeToLanguage('source_css'), null);
assert.equal(manager.scopeToLanguage('punctuation.definition.tag.html'), null);
});

});
Expand Down

0 comments on commit eea2028

Please sign in to comment.