diff --git a/src/vs/editor/node/textMate/TMSyntax.ts b/src/vs/editor/node/textMate/TMSyntax.ts index 9682c08a15b07..3cd7a4cd68fe4 100644 --- a/src/vs/editor/node/textMate/TMSyntax.ts +++ b/src/vs/editor/node/textMate/TMSyntax.ts @@ -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; } diff --git a/src/vs/editor/test/node/textMate/TMSyntax.test.ts b/src/vs/editor/test/node/textMate/TMSyntax.test.ts index f6e0499ca1bea..eccbcfd0b85a4 100644 --- a/src/vs/editor/test/node/textMate/TMSyntax.test.ts +++ b/src/vs/editor/test/node/textMate/TMSyntax.test.ts @@ -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); @@ -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'); @@ -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); }); });