mirror of
https://github.com/atom/atom.git
synced 2026-02-07 21:25:05 -05:00
Only load TextMate packages as needed in specs
Also: when a TextMate package is deactivated, remove its grammars
This commit is contained in:
committed by
Nathan Sobo
parent
8340a084d3
commit
8437f3ff7f
@@ -32,9 +32,14 @@ class Syntax
|
||||
|
||||
addGrammar: (grammar) ->
|
||||
@grammars.push(grammar)
|
||||
for fileType in grammar.fileTypes
|
||||
@grammarsByFileType[fileType] = grammar
|
||||
@grammarsByScopeName[grammar.scopeName] = grammar
|
||||
@grammarsByFileType[fileType] = grammar for fileType in grammar.fileTypes
|
||||
@grammarsByScopeName[grammar.scopeName] = grammar
|
||||
|
||||
removeGrammar: (grammar) ->
|
||||
if _.include(@grammars, grammar)
|
||||
_.remove(@grammars, grammar)
|
||||
delete @grammarsByFileType[fileType] for fileType in grammar.fileTypes
|
||||
delete @grammarsByScopeName[grammar.scopeName]
|
||||
|
||||
setGrammarOverrideForPath: (path, scopeName) ->
|
||||
@grammarOverridesByPath[path] = scopeName
|
||||
@@ -46,7 +51,9 @@ class Syntax
|
||||
@grammarOverridesByPath = {}
|
||||
|
||||
selectGrammar: (filePath, fileContents) ->
|
||||
|
||||
return @grammarsByFileType["txt"] ? @nullGrammar unless filePath
|
||||
|
||||
@grammarOverrideForPath(filePath) ?
|
||||
@grammarByFirstLineRegex(filePath, fileContents) ?
|
||||
@grammarByPath(filePath) ?
|
||||
|
||||
@@ -36,7 +36,8 @@ class TextMatePackage extends Package
|
||||
syntax.addProperties(selector, properties)
|
||||
|
||||
deactivate: ->
|
||||
# we should remove grammars and unregister properties, snippets, etc
|
||||
syntax.removeGrammar(grammar) for grammar in @grammars
|
||||
# we should also unregister properties, snippets, etc
|
||||
|
||||
legalGrammarExtensions: ['plist', 'tmLanguage', 'tmlanguage']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user