Load scoped properties after grammars load

This commit is contained in:
Kevin Sawicki
2013-04-23 09:38:22 -07:00
parent 4a5a155511
commit bef3c50fe5
2 changed files with 16 additions and 4 deletions

View File

@@ -58,7 +58,10 @@ _.extend atom,
_.clone(@activePackages)
loadPackages: ->
@loadPackage(path) for path in @getPackagePaths() when not @isPackageDisabled(path)
measure "load packages", =>
for path in @getPackagePaths() when not @isPackageDisabled(path)
measure "loading #{fsUtils.base(path)}", =>
@loadPackage(path)
loadPackage: (id, options) ->
if @isPackageDisabled(id)

View File

@@ -24,13 +24,13 @@ class TextMatePackage extends Package
@preferencesPath = fsUtils.join(@path, "Preferences")
@syntaxesPath = fsUtils.join(@path, "Syntaxes")
@grammars = []
@scopedProperties = []
load: ({sync}={}) ->
if sync
@loadGrammarsSync()
else
TextMatePackage.getLoadQueue().push(this)
@loadScopedProperties()
activate: ->
syntax.addGrammar(grammar) for grammar in @grammars
@@ -48,8 +48,13 @@ class TextMatePackage extends Package
if isDirectory
fsUtils.listAsync @syntaxesPath, @legalGrammarExtensions, (err, paths) =>
return console.log("Error loading grammars of TextMate package '#{@path}':", err.stack, err) if err
async.eachSeries paths, @loadGrammarAtPath, done
async.waterfall [
(next) =>
async.eachSeries paths, @loadGrammarAtPath, next
(next) =>
@loadScopedProperties()
next()
], done
loadGrammarAtPath: (path, done) =>
TextMateGrammar.load path, (err, grammar) =>
return console.log("Error loading grammar at path '#{path}':", err.stack ? err) if err
@@ -79,6 +84,10 @@ class TextMatePackage extends Package
selector = syntax.cssSelectorFromScopeSelector(scope) if scope?
@scopedProperties.push({selector, properties})
if atom.isPackageActive(@path)
for { selector, properties } in @scopedProperties
syntax.addProperties(@path, selector, properties)
getTextMatePreferenceObjects: ->
preferenceObjects = []
if fsUtils.exists(@preferencesPath)