From adcfcb789727db2a2eb0411b28abc7d5d52a7280 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 22 Mar 2013 17:34:35 -0600 Subject: [PATCH] Trigger 'grammars-loaded' when TextMate packages finish loading This is a temporary solution so we can merge async textmate package loading. I'd like to dispense with this event and consider each grammar individually as they are loaded. But this makes the behavior compatible with the old background-task-based behavior. --- src/app/text-mate-package.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/text-mate-package.coffee b/src/app/text-mate-package.coffee index e45a256f8..4d2af792f 100644 --- a/src/app/text-mate-package.coffee +++ b/src/app/text-mate-package.coffee @@ -12,6 +12,12 @@ class TextMatePackage extends Package @testName: (packageName) -> /(\.|_|-)tmbundle$/.test(packageName) + @getLoadQueue: -> + return @loadQueue if @loadQueue + @loadQueue = async.queue (pack, done) -> pack.loadGrammars(done) + @loadQueue.drain = -> syntax.trigger 'grammars-loaded' + @loadQueue + constructor: -> super @preferencesPath = fsUtils.join(@path, "Preferences") @@ -22,7 +28,7 @@ class TextMatePackage extends Package if sync @loadGrammarsSync() else - @loadGrammars() + TextMatePackage.getLoadQueue().push(this) @loadScopedProperties() legalGrammarExtensions: ['plist', 'tmLanguage', 'tmlanguage', 'cson', 'json'] @@ -38,6 +44,7 @@ class TextMatePackage extends Package TextMateGrammar.load path, (err, grammar) => return console.log("Error loading grammar at path '#{path}':", err.stack ? err) if err @addGrammar(grammar) + done() loadGrammarsSync: -> for path in fsUtils.list(@syntaxesPath, @legalGrammarExtensions) ? []