From 972fa41528ba8e2a8ac06cd577e2d88927f47649 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Thu, 6 Feb 2014 11:15:34 -0800 Subject: [PATCH 01/52] Package loading is always synchronous, activation can be async --- src/package-manager.coffee | 10 +++++----- src/package.coffee | 4 ++-- src/text-mate-package.coffee | 27 +++++++++++---------------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/package-manager.coffee b/src/package-manager.coffee index 85b598009..1629f3dfc 100644 --- a/src/package-manager.coffee +++ b/src/package-manager.coffee @@ -87,7 +87,7 @@ class PackageManager # Private: Activate a single package by name activatePackage: (name, options) -> return pack if pack = @getActivePackage(name) - if pack = @loadPackage(name, options) + if pack = @loadPackage(name) @activePackages[pack.name] = pack pack.activate(options) pack @@ -139,7 +139,7 @@ class PackageManager @observingDisabledPackages = true # Private: - loadPackages: (options) -> + loadPackages: -> # Ensure atom exports is already in the require cache so the load time # of the first package isn't skewed by being the first to require atom require '../exports/atom' @@ -147,16 +147,16 @@ class PackageManager packagePaths = @getAvailablePackagePaths() packagePaths = packagePaths.filter (packagePath) => not @isPackageDisabled(path.basename(packagePath)) packagePaths = _.uniq packagePaths, (packagePath) -> path.basename(packagePath) - @loadPackage(packagePath, options) for packagePath in packagePaths + @loadPackage(packagePath) for packagePath in packagePaths @emit 'loaded' # Private: - loadPackage: (nameOrPath, options) -> + loadPackage: (nameOrPath) -> if packagePath = @resolvePackagePath(nameOrPath) name = path.basename(nameOrPath) return pack if pack = @getLoadedPackage(name) - pack = Package.load(packagePath, options) + pack = Package.load(packagePath) @loadedPackages[pack.name] = pack if pack? pack else diff --git a/src/package.coffee b/src/package.coffee index 2c4eb9043..1a117f705 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -23,9 +23,9 @@ class Package pack - @load: (path, options) -> + @load: (path) -> pack = @build(path) - pack?.load(options) + pack?.load() pack @loadMetadata: (path, ignoreErrors=false) -> diff --git a/src/text-mate-package.coffee b/src/text-mate-package.coffee index 3daf8d353..420c321d3 100644 --- a/src/text-mate-package.coffee +++ b/src/text-mate-package.coffee @@ -12,13 +12,13 @@ class TextMatePackage extends Package packageName = path.basename(packageName) /(^language-.+)|((\.|_|-)tmbundle$)/.test(packageName) - @getLoadQueue: -> - return @loadQueue if @loadQueue - @loadQueue = async.queue (pack, done) -> + @getActivationQueue: -> + return @activationQueue if @activationQueue? + @activationQueue = async.queue (pack, done) -> pack.loadGrammars -> pack.loadScopedProperties(done) - @loadQueue + @activationQueue constructor: -> super @@ -28,21 +28,16 @@ class TextMatePackage extends Package getType: -> 'textmate' - load: ({sync}={}) -> + load: -> @measure 'loadTime', => @metadata = Package.loadMetadata(@path, true) - if sync - @loadGrammarsSync() - @loadScopedPropertiesSync() - else - TextMatePackage.getLoadQueue().push(this) - - activate: -> - @measure 'activateTime', => - grammar.activate() for grammar in @grammars - for { selector, properties } in @scopedProperties - atom.syntax.addProperties(@path, selector, properties) + activate: ({sync}={})-> + if sync + @loadGrammarsSync() + @loadScopedPropertiesSync() + else + TextMatePackage.getActivationQueue().push(this) activateConfig: -> # noop From 7a9a1ca213ee576036cf6c3c1dc7d723276526fc Mon Sep 17 00:00:00 2001 From: probablycorey Date: Thu, 6 Feb 2014 13:47:18 -0800 Subject: [PATCH 02/52] Allow sync or immediate to be used (prefer immediate) --- src/text-mate-package.coffee | 99 ++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/src/text-mate-package.coffee b/src/text-mate-package.coffee index 420c321d3..e8a627ffb 100644 --- a/src/text-mate-package.coffee +++ b/src/text-mate-package.coffee @@ -3,6 +3,7 @@ path = require 'path' _ = require 'underscore-plus' fs = require 'fs-plus' async = require 'async' +Q = require 'q' ### Internal ### @@ -12,13 +13,19 @@ class TextMatePackage extends Package packageName = path.basename(packageName) /(^language-.+)|((\.|_|-)tmbundle$)/.test(packageName) - @getActivationQueue: -> - return @activationQueue if @activationQueue? - @activationQueue = async.queue (pack, done) -> - pack.loadGrammars -> - pack.loadScopedProperties(done) + @addPackageToActivationQueue: (pack)-> + @activationQueue ?= [] + @activationQueue.push(pack) + @activateNextPacakageInQueue() if @activationQueue.length == 1 - @activationQueue + @activateNextPacakageInQueue: -> + if pack = @activationQueue[0] + pack.loadGrammars() + .then -> + pack.loadScopedProperties() + .then -> + @activationQueue.shift() + @activateNextPacakageInQueue() constructor: -> super @@ -32,12 +39,12 @@ class TextMatePackage extends Package @measure 'loadTime', => @metadata = Package.loadMetadata(@path, true) - activate: ({sync}={})-> - if sync + activate: ({sync, immediate}={})-> + if sync or immediate @loadGrammarsSync() @loadScopedPropertiesSync() else - TextMatePackage.getActivationQueue().push(this) + TextMatePackage.addPackageToActivationQueue(this) activateConfig: -> # noop @@ -47,29 +54,27 @@ class TextMatePackage extends Package legalGrammarExtensions: ['plist', 'tmLanguage', 'tmlanguage', 'json', 'cson'] - loadGrammars: (done) -> + loadGrammars: -> + deferred = Q.defer() fs.isDirectory @getSyntaxesPath(), (isDirectory) => - if isDirectory - fs.list @getSyntaxesPath(), @legalGrammarExtensions, (error, paths) => - if error? - console.log("Error loading grammars of TextMate package '#{@path}':", error.stack, error) - done() - else - async.eachSeries(paths, @loadGrammarAtPath, done) - else - done() + return deferred.resolve() unless isDirectory + + fs.list @getSyntaxesPath(), @legalGrammarExtensions, (error, paths) => + if error? + console.log("Error loading grammars of TextMate package '#{@path}':", error.stack, error) + deferred.resolve() + else + promise = Q() + promise = promise.then(=> @loadGrammarAtPath(path)) for path in paths + + deferred.promise loadGrammarAtPath: (grammarPath, done) => - atom.syntax.readGrammar grammarPath, (error, grammar) => - if error? - console.log("Error loading grammar at path '#{grammarPath}':", error.stack ? error) - else + Q.nfcall(atom.syntax.readGrammar, grammarPath) + .then (grammar) -> @addGrammar(grammar) - done?() - - loadGrammarsSync: -> - for grammarPath in fs.listSync(@getSyntaxesPath(), @legalGrammarExtensions) - @addGrammar(atom.syntax.readGrammarSync(grammarPath)) + .fail (error) -> + console.log("Error loading grammar at path '#{grammarPath}':", error.stack ? error) addGrammar: (grammar) -> @grammars.push(grammar) @@ -91,22 +96,6 @@ class TextMatePackage extends Package else path.join(@path, "Preferences") - loadScopedPropertiesSync: -> - for grammar in @getGrammars() - if properties = @propertiesFromTextMateSettings(grammar) - selector = atom.syntax.cssSelectorFromScopeSelector(grammar.scopeName) - @scopedProperties.push({selector, properties}) - - for preferencePath in fs.listSync(@getPreferencesPath()) - {scope, settings} = fs.readObjectSync(preferencePath) - if properties = @propertiesFromTextMateSettings(settings) - selector = atom.syntax.cssSelectorFromScopeSelector(scope) if scope? - @scopedProperties.push({selector, properties}) - - if @isActive() - for {selector, properties} in @scopedProperties - atom.syntax.addProperties(@path, selector, properties) - loadScopedProperties: (callback) -> scopedProperties = [] @@ -164,3 +153,25 @@ class TextMatePackage extends Package completions: textMateSettings.completions ) { editor: editorProperties } if _.size(editorProperties) > 0 + + # Deprecated + loadGrammarsSync: -> + for grammarPath in fs.listSync(@getSyntaxesPath(), @legalGrammarExtensions) + @addGrammar(atom.syntax.readGrammarSync(grammarPath)) + + # Deprecated + loadScopedPropertiesSync: -> + for grammar in @getGrammars() + if properties = @propertiesFromTextMateSettings(grammar) + selector = atom.syntax.cssSelectorFromScopeSelector(grammar.scopeName) + @scopedProperties.push({selector, properties}) + + for preferencePath in fs.listSync(@getPreferencesPath()) + {scope, settings} = fs.readObjectSync(preferencePath) + if properties = @propertiesFromTextMateSettings(settings) + selector = atom.syntax.cssSelectorFromScopeSelector(scope) if scope? + @scopedProperties.push({selector, properties}) + + if @isActive() + for {selector, properties} in @scopedProperties + atom.syntax.addProperties(@path, selector, properties) From 7686b348b1d73010a2b19a45d30e9bd8ac7d9807 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Thu, 6 Feb 2014 17:18:42 -0800 Subject: [PATCH 03/52] Upgrade to q@1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c464da57a..9e6022d21 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "pathwatcher": "0.14.2", "pegjs": "0.8.0", "property-accessors": "1.x", - "q": "0.9.7", + "q": "1.0.x", "scandal": "0.13.0", "season": "1.x", "semver": "1.1.4", From 0f68f095f14000f8bc38486c9ba0462291d3e114 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 11:18:44 -0800 Subject: [PATCH 04/52] Remove load and activate methods from ThemePackage I assume these were added to speed theme loading, but now that promises are being used it complicates overriding methods. From my tests removing these methods and relying on Atom Package's methods added ~2 ms per theme. --- src/theme-package.coffee | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/theme-package.coffee b/src/theme-package.coffee index 2115276fd..1ebbecebb 100644 --- a/src/theme-package.coffee +++ b/src/theme-package.coffee @@ -1,3 +1,4 @@ +Q = require 'q' AtomPackage = require './atom-package' Package = require './package' @@ -15,16 +16,3 @@ class ThemePackage extends AtomPackage disable: -> atom.config.removeAtKeyPath('core.themes', @metadata.name) - - load: -> - @measure 'loadTime', => - try - @metadata ?= Package.loadMetadata(@path) - catch e - console.warn "Failed to load theme named '#{@name}'", e.stack ? e - this - - activate: -> - @measure 'activateTime', => - @loadStylesheets() - @activateNow() From 28f0bf645f85d03950e2d2a46f069dcf965a82cd Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 11:20:33 -0800 Subject: [PATCH 05/52] Remove Package::isActive It didn't seem needed anymore --- src/package.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/package.coffee b/src/package.coffee index 1a117f705..44c1258e4 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -44,9 +44,6 @@ class Package constructor: (@path) -> @name = basename(@path) - isActive: -> - atom.packages.isPackageActive(@name) - enable: -> atom.config.removeAtKeyPath('core.disabledPackages', @metadata.name) From 9a51c2493767c34cdca48c4d21b791627cd2dfc7 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 11:21:42 -0800 Subject: [PATCH 06/52] Make AtomPackage:activate return a promise that is fulfilled when the package is activated. --- src/atom-package.coffee | 6 +++ src/package-manager.coffee | 15 ++++++- src/text-mate-package.coffee | 85 +++++++++++++++++------------------- src/theme-manager.coffee | 18 +++++--- 4 files changed, 71 insertions(+), 53 deletions(-) diff --git a/src/atom-package.coffee b/src/atom-package.coffee index 6546945bb..3d92aed83 100644 --- a/src/atom-package.coffee +++ b/src/atom-package.coffee @@ -2,6 +2,7 @@ Package = require './package' fs = require 'fs-plus' path = require 'path' _ = require 'underscore-plus' +Q = require 'q' {$} = require './space-pen-extensions' CSON = require 'season' {Emitter} = require 'emissary' @@ -60,6 +61,7 @@ class AtomPackage extends Package @scopedProperties = [] activate: ({immediate}={}) -> + @activationDeferred = Q.defer() @measure 'activateTime', => @activateResources() if @metadata.activationEvents? and not immediate @@ -67,6 +69,8 @@ class AtomPackage extends Package else @activateNow() + @activationDeferred.promise + activateNow: -> try @activateConfig() @@ -77,6 +81,8 @@ class AtomPackage extends Package catch e console.warn "Failed to activate package named '#{@name}'", e.stack + @activationDeferred.resolve() + activateConfig: -> return if @configActivated diff --git a/src/package-manager.coffee b/src/package-manager.coffee index 1629f3dfc..5cfa58c5e 100644 --- a/src/package-manager.coffee +++ b/src/package-manager.coffee @@ -1,6 +1,7 @@ {Emitter} = require 'emissary' fs = require 'fs-plus' _ = require 'underscore-plus' +Q = require 'q' Package = require './package' path = require 'path' @@ -85,7 +86,19 @@ class PackageManager @observeDisabledPackages() # Private: Activate a single package by name - activatePackage: (name, options) -> + activatePackage: (name, options={}) -> + if options.sync? or options.immediate? + return @activatePackageSync(name, options) + + if pack = @getActivePackage(name) + Q(pack) + else + pack = @loadPackage(name) + pack.activate(options).then => + @activePackages[pack.name] = pack + pack + + activatePackageSync: (name, options) -> return pack if pack = @getActivePackage(name) if pack = @loadPackage(name) @activePackages[pack.name] = pack diff --git a/src/text-mate-package.coffee b/src/text-mate-package.coffee index e8a627ffb..1b0269bc6 100644 --- a/src/text-mate-package.coffee +++ b/src/text-mate-package.coffee @@ -13,19 +13,12 @@ class TextMatePackage extends Package packageName = path.basename(packageName) /(^language-.+)|((\.|_|-)tmbundle$)/.test(packageName) - @addPackageToActivationQueue: (pack)-> - @activationQueue ?= [] - @activationQueue.push(pack) - @activateNextPacakageInQueue() if @activationQueue.length == 1 - - @activateNextPacakageInQueue: -> - if pack = @activationQueue[0] + @addToActivationPromise = (pack) -> + @activationPromise ?= Q() + @activationPromise = @activationPromise.then => pack.loadGrammars() - .then -> - pack.loadScopedProperties() - .then -> - @activationQueue.shift() - @activateNextPacakageInQueue() + .then -> pack.loadScopedProperties() + .fail (error) -> console.log pack.name, error constructor: -> super @@ -44,7 +37,7 @@ class TextMatePackage extends Package @loadGrammarsSync() @loadScopedPropertiesSync() else - TextMatePackage.addPackageToActivationQueue(this) + TextMatePackage.addToActivationPromise(this) activateConfig: -> # noop @@ -64,21 +57,25 @@ class TextMatePackage extends Package console.log("Error loading grammars of TextMate package '#{@path}':", error.stack, error) deferred.resolve() else - promise = Q() - promise = promise.then(=> @loadGrammarAtPath(path)) for path in paths + promises = paths.map (path) => @loadGrammarAtPath(path) + Q.all(promises).then -> deferred.resolve() deferred.promise - loadGrammarAtPath: (grammarPath, done) => - Q.nfcall(atom.syntax.readGrammar, grammarPath) - .then (grammar) -> - @addGrammar(grammar) - .fail (error) -> + loadGrammarAtPath: (grammarPath) -> + deferred = Q.defer() + atom.syntax.readGrammar grammarPath, (error, grammar) => + if error? console.log("Error loading grammar at path '#{grammarPath}':", error.stack ? error) + else + @addGrammar(grammar) + deferred.resolve() + + deferred.promise addGrammar: (grammar) -> @grammars.push(grammar) - grammar.activate() if @isActive() + grammar.activate() getGrammars: -> @grammars @@ -96,7 +93,7 @@ class TextMatePackage extends Package else path.join(@path, "Preferences") - loadScopedProperties: (callback) -> + loadScopedProperties: -> scopedProperties = [] for grammar in @getGrammars() @@ -104,38 +101,37 @@ class TextMatePackage extends Package selector = atom.syntax.cssSelectorFromScopeSelector(grammar.scopeName) scopedProperties.push({selector, properties}) - preferenceObjects = [] - done = => + @loadTextMatePreferenceObjects().then (preferenceObjects=[]) => for {scope, settings} in preferenceObjects if properties = @propertiesFromTextMateSettings(settings) selector = atom.syntax.cssSelectorFromScopeSelector(scope) if scope? scopedProperties.push({selector, properties}) @scopedProperties = scopedProperties - if @isActive() - for {selector, properties} in @scopedProperties - atom.syntax.addProperties(@path, selector, properties) - callback?() - @loadTextMatePreferenceObjects(preferenceObjects, done) + for {selector, properties} in @scopedProperties + atom.syntax.addProperties(@path, selector, properties) - loadTextMatePreferenceObjects: (preferenceObjects, done) -> + loadTextMatePreferenceObjects: -> + deferred = Q.defer() fs.isDirectory @getPreferencesPath(), (isDirectory) => - return done() unless isDirectory - + return deferred.resolve() unless isDirectory fs.list @getPreferencesPath(), (error, paths) => if error? console.log("Error loading preferences of TextMate package '#{@path}':", error.stack, error) - done() - return + deferred.resolve() + else + promises = paths.map (path) => @loadPreferencesAtPath(path) + Q.all(promises).then (preferenceObjects) -> deferred.resolve(preferenceObjects) - loadPreferencesAtPath = (preferencePath, done) -> - fs.readObject preferencePath, (error, preferences) => - if error? - console.warn("Failed to parse preference at path '#{preferencePath}'", error.stack, error) - else - preferenceObjects.push(preferences) - done() - async.eachSeries paths, loadPreferencesAtPath, done + deferred.promise + + loadPreferencesAtPath: (preferencePath) -> + deferred = Q.defer() + fs.readObject preferencePath, (error, preference) -> + if error? + console.warn("Failed to parse preference at path '#{preferencePath}'", error.stack, error) + deferred.resolve(preference) + deferred.promise propertiesFromTextMateSettings: (textMateSettings) -> if textMateSettings.shellVariables @@ -172,6 +168,5 @@ class TextMatePackage extends Package selector = atom.syntax.cssSelectorFromScopeSelector(scope) if scope? @scopedProperties.push({selector, properties}) - if @isActive() - for {selector, properties} in @scopedProperties - atom.syntax.addProperties(@path, selector, properties) + for {selector, properties} in @scopedProperties + atom.syntax.addProperties(@path, selector, properties) diff --git a/src/theme-manager.coffee b/src/theme-manager.coffee index b6eb0c590..9c01eb5ca 100644 --- a/src/theme-manager.coffee +++ b/src/theme-manager.coffee @@ -3,6 +3,7 @@ path = require 'path' _ = require 'underscore-plus' {Emitter} = require 'emissary' fs = require 'fs-plus' +Q = require 'q' {$} = require './space-pen-extensions' AtomPackage = require './atom-package' @@ -53,19 +54,22 @@ class ThemeManager themeNames.reverse() activateThemes: -> + deferred = Q.defer() + # atom.config.observe runs the callback once, then on subsequent changes. atom.config.observe 'core.themes', => @deactivateThemes() @refreshLessCache() # Update cache for packages in core.themes config - for themeName in @getEnabledThemeNames() - @packageManager.activatePackage(themeName) + promises = @getEnabledThemeNames().map (themeName) => @packageManager.activatePackage(themeName) + Q.all(promises).then => + @refreshLessCache() # Update cache again now that @getActiveThemes() is populated + @loadUserStylesheet() + @reloadBaseStylesheets() + @emit('reloaded') + deferred.resolve() - @refreshLessCache() # Update cache again now that @getActiveThemes() is populated - @loadUserStylesheet() - @reloadBaseStylesheets() - - @emit('reloaded') + deferred.promise deactivateThemes: -> @unwatchUserStylesheet() From d9a47f256c0c8705b244c5f311f4df39416e07d9 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 11:21:52 -0800 Subject: [PATCH 07/52] Update specs --- spec/atom-spec.coffee | 259 +++++++++++++++++++++------------ spec/theme-manager-spec.coffee | 109 +++++++++----- 2 files changed, 238 insertions(+), 130 deletions(-) diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index 24b646b95..8416a4ff2 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -32,12 +32,16 @@ describe "the `atom` global", -> describe ".unloadPackage(name)", -> describe "when the package is active", -> it "throws an error", -> - pack = atom.packages.activatePackage('package-with-main') - expect(atom.packages.isPackageLoaded(pack.name)).toBeTruthy() - expect(atom.packages.isPackageActive(pack.name)).toBeTruthy() - expect( -> atom.packages.unloadPackage(pack.name)).toThrow() - expect(atom.packages.isPackageLoaded(pack.name)).toBeTruthy() - expect(atom.packages.isPackageActive(pack.name)).toBeTruthy() + pack = null + waitsForPromise -> + atom.packages.activatePackage('package-with-main').then (p) -> pack = p + + runs -> + expect(atom.packages.isPackageLoaded(pack.name)).toBeTruthy() + expect(atom.packages.isPackageActive(pack.name)).toBeTruthy() + expect( -> atom.packages.unloadPackage(pack.name)).toThrow() + expect(atom.packages.isPackageLoaded(pack.name)).toBeTruthy() + expect(atom.packages.isPackageActive(pack.name)).toBeTruthy() describe "when the package is not loaded", -> it "throws an error", -> @@ -59,17 +63,25 @@ describe "the `atom` global", -> it "requires the module at the specified path", -> mainModule = require('./fixtures/packages/package-with-main/main-module') spyOn(mainModule, 'activate') - pack = atom.packages.activatePackage('package-with-main') - expect(mainModule.activate).toHaveBeenCalled() - expect(pack.mainModule).toBe mainModule + pack = null + waitsForPromise -> + atom.packages.activatePackage('package-with-main').then (p) -> pack = p + + runs -> + expect(mainModule.activate).toHaveBeenCalled() + expect(pack.mainModule).toBe mainModule describe "when the metadata does not specify a main module", -> it "requires index.coffee", -> indexModule = require('./fixtures/packages/package-with-index/index') spyOn(indexModule, 'activate') - pack = atom.packages.activatePackage('package-with-index') - expect(indexModule.activate).toHaveBeenCalled() - expect(pack.mainModule).toBe indexModule + pack = null + waitsForPromise -> + atom.packages.activatePackage('package-with-index').then (p) -> pack = p + + runs -> + expect(indexModule.activate).toHaveBeenCalled() + expect(pack.mainModule).toBe indexModule it "assigns config defaults from the module", -> expect(atom.config.get('package-with-config-defaults.numbers.one')).toBeUndefined() @@ -78,20 +90,23 @@ describe "the `atom` global", -> expect(atom.config.get('package-with-config-defaults.numbers.two')).toBe 2 describe "when the package metadata includes activation events", -> - [mainModule, pack] = [] + [mainModule, promise] = [] beforeEach -> mainModule = require './fixtures/packages/package-with-activation-events/index' spyOn(mainModule, 'activate').andCallThrough() AtomPackage = require '../src/atom-package' spyOn(AtomPackage.prototype, 'requireMainModule').andCallThrough() - pack = atom.packages.activatePackage('package-with-activation-events') + + promise = atom.packages.activatePackage('package-with-activation-events') + it "defers requiring/activating the main module until an activation event bubbles to the root view", -> - expect(pack.requireMainModule).not.toHaveBeenCalled() - expect(mainModule.activate).not.toHaveBeenCalled() + expect(promise.isFulfilled()).not.toBeTruthy() atom.workspaceView.trigger 'activation-event' - expect(mainModule.activate).toHaveBeenCalled() + + waitsForPromise -> + promise it "triggers the activation event on all handlers registered during activation", -> atom.workspaceView.openSync() @@ -116,13 +131,17 @@ describe "the `atom` global", -> expect(console.warn).not.toHaveBeenCalled() it "passes the activate method the package's previously serialized state if it exists", -> - pack = atom.packages.activatePackage("package-with-serialization") - expect(pack.mainModule.someNumber).not.toBe 77 - pack.mainModule.someNumber = 77 - atom.packages.deactivatePackage("package-with-serialization") - spyOn(pack.mainModule, 'activate').andCallThrough() - atom.packages.activatePackage("package-with-serialization") - expect(pack.mainModule.activate).toHaveBeenCalledWith({someNumber: 77}) + pack = null + waitsForPromise -> + atom.packages.activatePackage("package-with-serialization").then (p) -> pack = p + + runs -> + expect(pack.mainModule.someNumber).not.toBe 77 + pack.mainModule.someNumber = 77 + atom.packages.deactivatePackage("package-with-serialization") + spyOn(pack.mainModule, 'activate').andCallThrough() + atom.packages.activatePackage("package-with-serialization") + expect(pack.mainModule.activate).toHaveBeenCalledWith({someNumber: 77}) it "logs warning instead of throwing an exception if the package fails to load", -> atom.config.set("core.disabledPackages", []) @@ -245,29 +264,38 @@ describe "the `atom` global", -> describe "scoped-property loading", -> it "loads the scoped properties", -> - atom.packages.activatePackage("package-with-scoped-properties") - expect(atom.syntax.getProperty ['.source.omg'], 'editor.increaseIndentPattern').toBe '^a' + waitsForPromise -> + atom.packages.activatePackage("package-with-scoped-properties") + + runs -> + expect(atom.syntax.getProperty ['.source.omg'], 'editor.increaseIndentPattern').toBe '^a' describe "textmate packages", -> it "loads the package's grammars", -> expect(atom.syntax.selectGrammar("file.rb").name).toBe "Null Grammar" - atom.packages.activatePackage('language-ruby', sync: true) - expect(atom.syntax.selectGrammar("file.rb").name).toBe "Ruby" + + waitsForPromise -> + atom.packages.activatePackage('language-ruby') + + runs -> + expect(atom.syntax.selectGrammar("file.rb").name).toBe "Ruby" it "translates the package's scoped properties to Atom terms", -> expect(atom.syntax.getProperty(['.source.ruby'], 'editor.commentStart')).toBeUndefined() - atom.packages.activatePackage('language-ruby', sync: true) - expect(atom.syntax.getProperty(['.source.ruby'], 'editor.commentStart')).toBe '# ' + + waitsForPromise -> + atom.packages.activatePackage('language-ruby') + + runs -> + expect(atom.syntax.getProperty(['.source.ruby'], 'editor.commentStart')).toBe '# ' describe "when the package has no grammars but does have preferences", -> it "loads the package's preferences as scoped properties", -> jasmine.unspy(window, 'setTimeout') spyOn(atom.syntax, 'addProperties').andCallThrough() - atom.packages.activatePackage('package-with-preferences-tmbundle') - - waitsFor -> - atom.syntax.addProperties.callCount > 0 + waitsForPromise -> + atom.packages.activatePackage('package-with-preferences-tmbundle') runs -> expect(atom.syntax.getProperty(['.source.pref'], 'editor.increaseIndentPattern')).toBe '^abc$' @@ -275,30 +303,43 @@ describe "the `atom` global", -> describe ".deactivatePackage(id)", -> describe "atom packages", -> it "calls `deactivate` on the package's main module if activate was successful", -> - pack = atom.packages.activatePackage("package-with-deactivate") - expect(atom.packages.isPackageActive("package-with-deactivate")).toBeTruthy() - spyOn(pack.mainModule, 'deactivate').andCallThrough() + pack = null + waitsForPromise -> + atom.packages.activatePackage("package-with-deactivate").then (p) -> pack = p - atom.packages.deactivatePackage("package-with-deactivate") - expect(pack.mainModule.deactivate).toHaveBeenCalled() - expect(atom.packages.isPackageActive("package-with-module")).toBeFalsy() + runs -> + expect(atom.packages.isPackageActive("package-with-deactivate")).toBeTruthy() + spyOn(pack.mainModule, 'deactivate').andCallThrough() - spyOn(console, 'warn') - badPack = atom.packages.activatePackage("package-that-throws-on-activate") - expect(atom.packages.isPackageActive("package-that-throws-on-activate")).toBeTruthy() - spyOn(badPack.mainModule, 'deactivate').andCallThrough() + atom.packages.deactivatePackage("package-with-deactivate") + expect(pack.mainModule.deactivate).toHaveBeenCalled() + expect(atom.packages.isPackageActive("package-with-module")).toBeFalsy() - atom.packages.deactivatePackage("package-that-throws-on-activate") - expect(badPack.mainModule.deactivate).not.toHaveBeenCalled() - expect(atom.packages.isPackageActive("package-that-throws-on-activate")).toBeFalsy() + spyOn(console, 'warn') + + badPack = null + waitsForPromise -> + atom.packages.activatePackage("package-that-throws-on-activate").then (p) -> badPack = p + + runs -> + expect(atom.packages.isPackageActive("package-that-throws-on-activate")).toBeTruthy() + spyOn(badPack.mainModule, 'deactivate').andCallThrough() + + atom.packages.deactivatePackage("package-that-throws-on-activate") + expect(badPack.mainModule.deactivate).not.toHaveBeenCalled() + expect(atom.packages.isPackageActive("package-that-throws-on-activate")).toBeFalsy() it "does not serialize packages that have not been activated called on their main module", -> spyOn(console, 'warn') - badPack = atom.packages.activatePackage("package-that-throws-on-activate") - spyOn(badPack.mainModule, 'serialize').andCallThrough() + badPack = null + waitsForPromise -> + atom.packages.activatePackage("package-that-throws-on-activate").then (p) -> badPack = p - atom.packages.deactivatePackage("package-that-throws-on-activate") - expect(badPack.mainModule.serialize).not.toHaveBeenCalled() + runs -> + spyOn(badPack.mainModule, 'serialize').andCallThrough() + + atom.packages.deactivatePackage("package-that-throws-on-activate") + expect(badPack.mainModule.serialize).not.toHaveBeenCalled() it "absorbs exceptions that are thrown by the package module's serialize methods", -> spyOn(console, 'error') @@ -310,32 +351,44 @@ describe "the `atom` global", -> expect(console.error).toHaveBeenCalled() it "removes the package's grammars", -> - atom.packages.activatePackage('package-with-grammars') - atom.packages.deactivatePackage('package-with-grammars') - expect(atom.syntax.selectGrammar('a.alot').name).toBe 'Null Grammar' - expect(atom.syntax.selectGrammar('a.alittle').name).toBe 'Null Grammar' + waitsForPromise -> + atom.packages.activatePackage('package-with-grammars') + + runs -> + atom.packages.deactivatePackage('package-with-grammars') + expect(atom.syntax.selectGrammar('a.alot').name).toBe 'Null Grammar' + expect(atom.syntax.selectGrammar('a.alittle').name).toBe 'Null Grammar' it "removes the package's keymaps", -> - atom.packages.activatePackage('package-with-keymaps') - atom.packages.deactivatePackage('package-with-keymaps') - expect(atom.keymap.keyBindingsForKeystrokeMatchingElement('ctrl-z', $$ -> @div class: 'test-1')).toHaveLength 0 - expect(atom.keymap.keyBindingsForKeystrokeMatchingElement('ctrl-z', $$ -> @div class: 'test-2')).toHaveLength 0 + waitsForPromise -> + atom.packages.activatePackage('package-with-keymaps') + + runs -> + atom.packages.deactivatePackage('package-with-keymaps') + expect(atom.keymap.keyBindingsForKeystrokeMatchingElement('ctrl-z', $$ -> @div class: 'test-1')).toHaveLength 0 + expect(atom.keymap.keyBindingsForKeystrokeMatchingElement('ctrl-z', $$ -> @div class: 'test-2')).toHaveLength 0 it "removes the package's stylesheets", -> - atom.packages.activatePackage('package-with-stylesheets') - atom.packages.deactivatePackage('package-with-stylesheets') - one = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/stylesheets/1.css") - two = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/stylesheets/2.less") - three = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/stylesheets/3.css") - expect(atom.themes.stylesheetElementForId(one)).not.toExist() - expect(atom.themes.stylesheetElementForId(two)).not.toExist() - expect(atom.themes.stylesheetElementForId(three)).not.toExist() + waitsForPromise -> + atom.packages.activatePackage('package-with-stylesheets') + + runs -> + atom.packages.deactivatePackage('package-with-stylesheets') + one = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/stylesheets/1.css") + two = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/stylesheets/2.less") + three = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/stylesheets/3.css") + expect(atom.themes.stylesheetElementForId(one)).not.toExist() + expect(atom.themes.stylesheetElementForId(two)).not.toExist() + expect(atom.themes.stylesheetElementForId(three)).not.toExist() it "removes the package's scoped-properties", -> - atom.packages.activatePackage("package-with-scoped-properties") - expect(atom.syntax.getProperty ['.source.omg'], 'editor.increaseIndentPattern').toBe '^a' - atom.packages.deactivatePackage("package-with-scoped-properties") - expect(atom.syntax.getProperty ['.source.omg'], 'editor.increaseIndentPattern').toBeUndefined() + waitsForPromise -> + atom.packages.activatePackage("package-with-scoped-properties") + + runs -> + expect(atom.syntax.getProperty ['.source.omg'], 'editor.increaseIndentPattern').toBe '^a' + atom.packages.deactivatePackage("package-with-scoped-properties") + expect(atom.syntax.getProperty ['.source.omg'], 'editor.increaseIndentPattern').toBeUndefined() describe "textmate packages", -> it "removes the package's grammars", -> @@ -382,7 +435,7 @@ describe "the `atom` global", -> themes = themeActivator.mostRecentCall.args[0] expect(['theme']).toContain(theme.getType()) for theme in themes - describe ".en/disablePackage()", -> + describe ".enablePackage() and disablePackage()", -> describe "with packages", -> it ".enablePackage() enables a disabled package", -> packageName = 'package-with-main' @@ -391,28 +444,36 @@ describe "the `atom` global", -> expect(atom.config.get('core.disabledPackages')).toContain packageName pack = atom.packages.enablePackage(packageName) - loadedPackages = atom.packages.getLoadedPackages() - activatedPackages = atom.packages.getActivePackages() - expect(loadedPackages).toContain(pack) - expect(activatedPackages).toContain(pack) - expect(atom.config.get('core.disabledPackages')).not.toContain packageName + activatedPackages = null + waitsFor -> + activatedPackages = atom.packages.getActivePackages() + activatedPackages.length > 0 + + runs -> + expect(loadedPackages).toContain(pack) + expect(activatedPackages).toContain(pack) + expect(atom.config.get('core.disabledPackages')).not.toContain packageName it ".disablePackage() disables an enabled package", -> packageName = 'package-with-main' - atom.packages.activatePackage(packageName) - atom.packages.observeDisabledPackages() - expect(atom.config.get('core.disabledPackages')).not.toContain packageName + waitsForPromise -> + atom.packages.activatePackage(packageName) - pack = atom.packages.disablePackage(packageName) + runs -> + atom.packages.observeDisabledPackages() + expect(atom.config.get('core.disabledPackages')).not.toContain packageName - activatedPackages = atom.packages.getActivePackages() - expect(activatedPackages).not.toContain(pack) - expect(atom.config.get('core.disabledPackages')).toContain packageName + pack = atom.packages.disablePackage(packageName) + + activatedPackages = atom.packages.getActivePackages() + expect(activatedPackages).not.toContain(pack) + expect(atom.config.get('core.disabledPackages')).toContain packageName describe "with themes", -> beforeEach -> - atom.themes.activateThemes() + waitsForPromise -> + atom.themes.activateThemes() afterEach -> atom.themes.deactivateThemes() @@ -426,18 +487,24 @@ describe "the `atom` global", -> # enabling of theme pack = atom.packages.enablePackage(packageName) - activatedPackages = atom.packages.getActivePackages() - expect(activatedPackages).toContain(pack) - expect(atom.config.get('core.themes')).toContain packageName - expect(atom.config.get('core.disabledPackages')).not.toContain packageName - # disabling of theme - pack = atom.packages.disablePackage(packageName) - activatedPackages = atom.packages.getActivePackages() - expect(activatedPackages).not.toContain(pack) - expect(atom.config.get('core.themes')).not.toContain packageName - expect(atom.config.get('core.themes')).not.toContain packageName - expect(atom.config.get('core.disabledPackages')).not.toContain packageName + activatedPackages = null + waitsFor -> + activatedPackages = atom.packages.getActivePackages() + activatedPackages.length > 0 + + runs -> + expect(activatedPackages).toContain(pack) + expect(atom.config.get('core.themes')).toContain packageName + expect(atom.config.get('core.disabledPackages')).not.toContain packageName + + # disabling of theme + pack = atom.packages.disablePackage(packageName) + activatedPackages = atom.packages.getActivePackages() + expect(activatedPackages).not.toContain(pack) + expect(atom.config.get('core.themes')).not.toContain packageName + expect(atom.config.get('core.themes')).not.toContain packageName + expect(atom.config.get('core.disabledPackages')).not.toContain packageName describe ".isReleasedVersion()", -> it "returns false if the version is a SHA and true otherwise", -> diff --git a/spec/theme-manager-spec.coffee b/spec/theme-manager-spec.coffee index c8d257b54..384844e93 100644 --- a/spec/theme-manager-spec.coffee +++ b/spec/theme-manager-spec.coffee @@ -26,11 +26,14 @@ describe "ThemeManager", -> expect(themes.length).toBeGreaterThan(2) it 'getActiveThemes get all the active themes', -> - themeManager.activateThemes() - names = atom.config.get('core.themes') - expect(names.length).toBeGreaterThan(0) - themes = themeManager.getActiveThemes() - expect(themes).toHaveLength(names.length) + waitsForPromise -> + themeManager.activateThemes() + + runs -> + names = atom.config.get('core.themes') + expect(names.length).toBeGreaterThan(0) + themes = themeManager.getActiveThemes() + expect(themes).toHaveLength(names.length) describe "getImportPaths()", -> it "returns the theme directories before the themes are loaded", -> @@ -51,29 +54,58 @@ describe "ThemeManager", -> it "add/removes stylesheets to reflect the new config value", -> themeManager.on 'reloaded', reloadHandler = jasmine.createSpy() spyOn(themeManager, 'getUserStylesheetPath').andCallFake -> null - themeManager.activateThemes() - atom.config.set('core.themes', []) - expect($('style.theme').length).toBe 0 - expect(reloadHandler).toHaveBeenCalled() + waitsForPromise -> + themeManager.activateThemes() - atom.config.set('core.themes', ['atom-dark-syntax']) - expect($('style.theme').length).toBe 1 - expect($('style.theme:eq(0)').attr('id')).toMatch /atom-dark-syntax/ + runs -> + reloadHandler.reset() + atom.config.set('core.themes', []) - atom.config.set('core.themes', ['atom-light-syntax', 'atom-dark-syntax']) - expect($('style.theme').length).toBe 2 - expect($('style.theme:eq(0)').attr('id')).toMatch /atom-dark-syntax/ - expect($('style.theme:eq(1)').attr('id')).toMatch /atom-light-syntax/ + waitsFor -> + reloadHandler.callCount == 1 - atom.config.set('core.themes', []) - expect($('style.theme').length).toBe 0 + runs -> + reloadHandler.reset() + expect($('style.theme')).toHaveLength 0 + atom.config.set('core.themes', ['atom-dark-syntax']) - # atom-dark-ui has an directory path, the syntax one doesn't - atom.config.set('core.themes', ['theme-with-index-less', 'atom-dark-ui']) - importPaths = themeManager.getImportPaths() - expect(importPaths.length).toBe 1 - expect(importPaths[0]).toContain 'atom-dark-ui' + waitsFor -> + reloadHandler.callCount == 1 + + runs -> + reloadHandler.reset() + expect($('style.theme')).toHaveLength 1 + expect($('style.theme:eq(0)').attr('id')).toMatch /atom-dark-syntax/ + atom.config.set('core.themes', ['atom-light-syntax', 'atom-dark-syntax']) + + waitsFor -> + reloadHandler.callCount == 1 + + runs -> + reloadHandler.reset() + expect($('style.theme')).toHaveLength 2 + expect($('style.theme:eq(0)').attr('id')).toMatch /atom-dark-syntax/ + expect($('style.theme:eq(1)').attr('id')).toMatch /atom-light-syntax/ + atom.config.set('core.themes', []) + + waitsFor -> + reloadHandler.callCount == 1 + + runs -> + reloadHandler.reset() + expect($('style.theme')).toHaveLength 0 + # atom-dark-ui has an directory path, the syntax one doesn't + atom.config.set('core.themes', ['theme-with-index-less', 'atom-dark-ui']) + + waitsFor -> + reloadHandler.callCount == 1 + + runs -> + expect($('style.theme')).toHaveLength 2 + importPaths = themeManager.getImportPaths() + expect(importPaths.length).toBe 1 + expect(importPaths[0]).toContain 'atom-dark-ui' describe "when a theme fails to load", -> it "logs a warning", -> @@ -145,18 +177,25 @@ describe "ThemeManager", -> atom.workspaceView = new WorkspaceView atom.workspaceView.append $$ -> @div class: 'editor' atom.workspaceView.attachToDom() - themeManager.activateThemes() + + waitsForPromise -> + themeManager.activateThemes() it "loads the correct values from the theme's ui-variables file", -> + themeManager.on 'reloaded', reloadHandler = jasmine.createSpy() atom.config.set('core.themes', ['theme-with-ui-variables']) - # an override loaded in the base css - expect(atom.workspaceView.css("background-color")).toBe "rgb(0, 0, 255)" + waitsFor -> + reloadHandler.callCount > 0 - # from within the theme itself - expect($(".editor").css("padding-top")).toBe "150px" - expect($(".editor").css("padding-right")).toBe "150px" - expect($(".editor").css("padding-bottom")).toBe "150px" + runs -> + # an override loaded in the base css + expect(atom.workspaceView.css("background-color")).toBe "rgb(0, 0, 255)" + + # from within the theme itself + expect($(".editor").css("padding-top")).toBe "150px" + expect($(".editor").css("padding-right")).toBe "150px" + expect($(".editor").css("padding-bottom")).toBe "150px" describe "when the user stylesheet changes", -> it "reloads it", -> @@ -164,12 +203,14 @@ describe "ThemeManager", -> fs.writeFileSync(userStylesheetPath, 'body {border-style: dotted !important;}') spyOn(themeManager, 'getUserStylesheetPath').andReturn userStylesheetPath - themeManager.activateThemes() - expect($(document.body).css('border-style')).toBe 'dotted' - spyOn(themeManager, 'loadUserStylesheet').andCallThrough() + waitsForPromise -> + themeManager.activateThemes() - fs.writeFileSync(userStylesheetPath, 'body {border-style: dashed}') + runs -> + expect($(document.body).css('border-style')).toBe 'dotted' + spyOn(themeManager, 'loadUserStylesheet').andCallThrough() + fs.writeFileSync(userStylesheetPath, 'body {border-style: dashed}') waitsFor -> themeManager.loadUserStylesheet.callCount is 1 From 802ec9d8c29514f4d6138987c39935157367bff2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 13:47:04 -0800 Subject: [PATCH 08/52] Upgrade to command-logger@0.11.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e6022d21..5aae19a63 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "background-tips": "0.5.0", "bookmarks": "0.18.0", "bracket-matcher": "0.19.0", - "command-logger": "0.10.0", + "command-logger": "0.11.0", "command-palette": "0.15.0", "dev-live-reload": "0.23.0", "editor-stats": "0.12.0", From fa45af588e1e75fe9cfaafe5711cc51ced0d1cfe Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 13:50:11 -0800 Subject: [PATCH 09/52] Upgrade to wrap-guide@0.13.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5aae19a63..0a4bac559 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "visual-bell": "0.6.0", "welcome": "0.4.0", "whitespace": "0.10.0", - "wrap-guide": "0.12.0", + "wrap-guide": "0.13.0", "language-c": "0.2.0", "language-clojure": "0.1.0", "language-coffee-script": "0.6.0", From 01f3f88c6c0c71ab12582daa79b91f8a2dcd224d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 13:51:33 -0800 Subject: [PATCH 10/52] Upgrade to whitespace@0.11.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a4bac559..93159d602 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "update-package-dependencies": "0.2.0", "visual-bell": "0.6.0", "welcome": "0.4.0", - "whitespace": "0.10.0", + "whitespace": "0.11.0", "wrap-guide": "0.13.0", "language-c": "0.2.0", "language-clojure": "0.1.0", From c81fcac1087426fdfcaeefa767a7bf1cdead0404 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 13:57:43 -0800 Subject: [PATCH 11/52] Upgrade to tree-view@0.68.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93159d602..4d8baae89 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "terminal": "0.27.0", "timecop": "0.13.0", "to-the-hubs": "0.19.0", - "tree-view": "0.67.0", + "tree-view": "0.68.0", "update-package-dependencies": "0.2.0", "visual-bell": "0.6.0", "welcome": "0.4.0", From d64ff4d598546c1335f358d66b8105cfd7b092c5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 13:58:42 -0800 Subject: [PATCH 12/52] Upgrade to tree-view@0.69.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d8baae89..4c796225a 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "terminal": "0.27.0", "timecop": "0.13.0", "to-the-hubs": "0.19.0", - "tree-view": "0.68.0", + "tree-view": "0.69.0", "update-package-dependencies": "0.2.0", "visual-bell": "0.6.0", "welcome": "0.4.0", From efbf961c4bf432370122b4ad488252ed32d59719 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 14:00:38 -0800 Subject: [PATCH 13/52] Upgrade to tabs@0.19.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c796225a..fe0ff8a81 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "status-bar": "0.32.0", "styleguide": "0.22.0", "symbols-view": "0.31.0", - "tabs": "0.18.0", + "tabs": "0.19.0", "terminal": "0.27.0", "timecop": "0.13.0", "to-the-hubs": "0.19.0", From 2d934028587c083c463fabcf1d8760690b206773 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 14:03:18 -0800 Subject: [PATCH 14/52] Update to autocomplete@0.22.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fe0ff8a81..185dc6ffe 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "solarized-dark-syntax": "0.9.0", "solarized-light-syntax": "0.5.0", "archive-view": "0.21.0", - "autocomplete": "0.21.0", + "autocomplete": "0.22.0", "autoflow": "0.12.0", "autosave": "0.10.0", "background-tips": "0.5.0", From 625a61a18fbef9a58e719a83cce6bc6ce540eefc Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 14:12:16 -0800 Subject: [PATCH 15/52] Upgrade to autoflow@0.13.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 185dc6ffe..25167268e 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "solarized-light-syntax": "0.5.0", "archive-view": "0.21.0", "autocomplete": "0.22.0", - "autoflow": "0.12.0", + "autoflow": "0.13.0", "autosave": "0.10.0", "background-tips": "0.5.0", "bookmarks": "0.18.0", From 69545cba61ddc7aa77246438a1c69887f2ecaca2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 14:25:30 -0800 Subject: [PATCH 16/52] Upgrade to symbols-view@0.32.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 25167268e..3b865ec1a 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "spell-check": "0.22.0", "status-bar": "0.32.0", "styleguide": "0.22.0", - "symbols-view": "0.31.0", + "symbols-view": "0.32.0", "tabs": "0.19.0", "terminal": "0.27.0", "timecop": "0.13.0", From d5222f22eae26d92449178746e1db96c6b1b6e05 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 14:27:24 -0800 Subject: [PATCH 17/52] Upgrade to bracket-matcher@0.20.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b865ec1a..67b0f3614 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "autosave": "0.10.0", "background-tips": "0.5.0", "bookmarks": "0.18.0", - "bracket-matcher": "0.19.0", + "bracket-matcher": "0.20.0", "command-logger": "0.11.0", "command-palette": "0.15.0", "dev-live-reload": "0.23.0", From 81fd2bbf2e5428afc39ee90a903f3a5453e8a330 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 14:31:04 -0800 Subject: [PATCH 18/52] Upgrade to command-pallete@0.16.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 67b0f3614..5bb169f62 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "bookmarks": "0.18.0", "bracket-matcher": "0.20.0", "command-logger": "0.11.0", - "command-palette": "0.15.0", + "command-palette": "0.16.0", "dev-live-reload": "0.23.0", "editor-stats": "0.12.0", "exception-reporting": "0.13.0", From 009cbfd41865ca0d5eda1cd79185fefe890dc925 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 14:28:15 -0800 Subject: [PATCH 19/52] Upgrade to snippets@0.25.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5bb169f62..4b4f9bdeb 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "package-generator": "0.25.0", "release-notes": "0.17.0", "settings-view": "0.67.0", - "snippets": "0.24.0", + "snippets": "0.25.0", "spell-check": "0.22.0", "status-bar": "0.32.0", "styleguide": "0.22.0", From 9c1fa74d2f1efc67466a6f1fa92f04e760b0bc33 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 14:29:20 -0800 Subject: [PATCH 20/52] Upgrade to snippets@0.26.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b4f9bdeb..86de58630 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "package-generator": "0.25.0", "release-notes": "0.17.0", "settings-view": "0.67.0", - "snippets": "0.25.0", + "snippets": "0.26.0", "spell-check": "0.22.0", "status-bar": "0.32.0", "styleguide": "0.22.0", From df1a792675f6341dc96d97e5182e23377ecc80b6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 14:52:10 -0800 Subject: [PATCH 21/52] Upgrade to settings-view@0.71.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 86de58630..0c340de29 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "metrics": "0.24.0", "package-generator": "0.25.0", "release-notes": "0.17.0", - "settings-view": "0.67.0", + "settings-view": "0.71.0", "snippets": "0.26.0", "spell-check": "0.22.0", "status-bar": "0.32.0", From 5d2c6ea4b407854a135f5104881b12464924dc0f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 14:55:58 -0800 Subject: [PATCH 22/52] Upgrade to package-generator@0.26.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c340de29..979dc535d 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "link": "0.15.0", "markdown-preview": "0.25.1", "metrics": "0.24.0", - "package-generator": "0.25.0", + "package-generator": "0.26.0", "release-notes": "0.17.0", "settings-view": "0.71.0", "snippets": "0.26.0", From e567702e3f73de7552fdadefa5a799f8a03225cd Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 14:58:13 -0800 Subject: [PATCH 23/52] Upgrade to metrics@0.25.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 979dc535d..aca2f5096 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "keybinding-resolver": "0.9.0", "link": "0.15.0", "markdown-preview": "0.25.1", - "metrics": "0.24.0", + "metrics": "0.25.0", "package-generator": "0.26.0", "release-notes": "0.17.0", "settings-view": "0.71.0", From c1e8505ebfef349799ef924fe891c657eaf20e53 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 14:59:35 -0800 Subject: [PATCH 24/52] Upgrade to link@0.16.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aca2f5096..ad4063169 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "grammar-selector": "0.18.0", "image-view": "0.18.0", "keybinding-resolver": "0.9.0", - "link": "0.15.0", + "link": "0.16.0", "markdown-preview": "0.25.1", "metrics": "0.25.0", "package-generator": "0.26.0", From ac6675380ccfdcf1eebeebc6bba280bb04ac81f6 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 15:00:52 -0800 Subject: [PATCH 25/52] Upgrade to dev-live-reload@0.24.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad4063169..b57ff6aa4 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "bracket-matcher": "0.20.0", "command-logger": "0.11.0", "command-palette": "0.16.0", - "dev-live-reload": "0.23.0", + "dev-live-reload": "0.24.0", "editor-stats": "0.12.0", "exception-reporting": "0.13.0", "feedback": "0.22.0", From 3534ac0f32a64d9377da6451f354863b75145799 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 15:01:13 -0800 Subject: [PATCH 26/52] Upgrade to image-view@0.19.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b57ff6aa4..955e2a913 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "github-sign-in": "0.18.0", "go-to-line": "0.16.0", "grammar-selector": "0.18.0", - "image-view": "0.18.0", + "image-view": "0.19.0", "keybinding-resolver": "0.9.0", "link": "0.16.0", "markdown-preview": "0.25.1", From e499e32c24359574ea8dc12c77666223224d74de Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 15:03:09 -0800 Subject: [PATCH 27/52] Upgrade to editor-stats@0.13.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 955e2a913..1a41e81bf 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "command-logger": "0.11.0", "command-palette": "0.16.0", "dev-live-reload": "0.24.0", - "editor-stats": "0.12.0", + "editor-stats": "0.13.0", "exception-reporting": "0.13.0", "feedback": "0.22.0", "find-and-replace": "0.81.0", From f3be8760650eef1c8407747ce53eff0b417c70bf Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 15:06:56 -0800 Subject: [PATCH 28/52] Upgrade to grammar-selector@0.19.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a41e81bf..7b8c925fe 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "git-diff": "0.23.0", "github-sign-in": "0.18.0", "go-to-line": "0.16.0", - "grammar-selector": "0.18.0", + "grammar-selector": "0.19.0", "image-view": "0.19.0", "keybinding-resolver": "0.9.0", "link": "0.16.0", From 163150dc871d7834e029943cef46434fd8c4786f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 15:09:43 -0800 Subject: [PATCH 29/52] Upgrade to git-diff@0.24.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b8c925fe..9243c96dc 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "find-and-replace": "0.81.0", "fuzzy-finder": "0.32.0", "gists": "0.16.0", - "git-diff": "0.23.0", + "git-diff": "0.24.0", "github-sign-in": "0.18.0", "go-to-line": "0.16.0", "grammar-selector": "0.19.0", From 4b9aa1862804a7a6cbce9384ae681f04d4fd69e4 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 15:10:30 -0800 Subject: [PATCH 30/52] Upgrade to feedback@0.23.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9243c96dc..bc8f60967 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "dev-live-reload": "0.24.0", "editor-stats": "0.13.0", "exception-reporting": "0.13.0", - "feedback": "0.22.0", + "feedback": "0.23.0", "find-and-replace": "0.81.0", "fuzzy-finder": "0.32.0", "gists": "0.16.0", From 73cc1dadae12a6e5344a60b9ade5e214c2664e96 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 15:13:24 -0800 Subject: [PATCH 31/52] Upgrade to fuzzy-finder@0.34.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bc8f60967..015af9d43 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "dev-live-reload": "0.24.0", "editor-stats": "0.13.0", "exception-reporting": "0.13.0", - "feedback": "0.23.0", + "feedback": "0.24.0", "find-and-replace": "0.81.0", "fuzzy-finder": "0.32.0", "gists": "0.16.0", From 42a777e8223b1f29c1be0bb41ca2f88fe740d37e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 15:12:16 -0800 Subject: [PATCH 32/52] Upgrade to gists@0.17.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 015af9d43..d70c96847 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "feedback": "0.24.0", "find-and-replace": "0.81.0", "fuzzy-finder": "0.32.0", - "gists": "0.16.0", + "gists": "0.17.0", "git-diff": "0.24.0", "github-sign-in": "0.18.0", "go-to-line": "0.16.0", From fe5640df4b2e00ce3965a898da2c1a190faec594 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 15:22:58 -0800 Subject: [PATCH 33/52] Return promise if it already exists This prevents successive calls to atom.packages.activatePackage from activating an AtomPackage multiple times. --- spec/atom-spec.coffee | 14 +++++++++++++- src/atom-package.coffee | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index 8416a4ff2..9e37e2ac6 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -1,6 +1,7 @@ {$, $$, fs, WorkspaceView} = require 'atom' Exec = require('child_process').exec path = require 'path' +AtomPackage = require '../src/atom-package' ThemeManager = require '../src/theme-manager' describe "the `atom` global", -> @@ -58,6 +59,18 @@ describe "the `atom` global", -> describe ".activatePackage(id)", -> describe "atom packages", -> + describe "when called multiple times", -> + it "it only calls activate on the package once", -> + spyOn(AtomPackage.prototype, 'activateNow').andCallThrough() + atom.packages.activatePackage('package-with-index') + atom.packages.activatePackage('package-with-index') + + waitsForPromise -> + atom.packages.activatePackage('package-with-index') + + runs -> + expect(AtomPackage.prototype.activateNow.callCount).toBe 1 + describe "when the package has a main module", -> describe "when the metadata specifies a main module path˜", -> it "requires the module at the specified path", -> @@ -100,7 +113,6 @@ describe "the `atom` global", -> promise = atom.packages.activatePackage('package-with-activation-events') - it "defers requiring/activating the main module until an activation event bubbles to the root view", -> expect(promise.isFulfilled()).not.toBeTruthy() atom.workspaceView.trigger 'activation-event' diff --git a/src/atom-package.coffee b/src/atom-package.coffee index 3d92aed83..b37e5d66d 100644 --- a/src/atom-package.coffee +++ b/src/atom-package.coffee @@ -61,6 +61,8 @@ class AtomPackage extends Package @scopedProperties = [] activate: ({immediate}={}) -> + return @activationDeferred.promise if @activationDeferred? + @activationDeferred = Q.defer() @measure 'activateTime', => @activateResources() From e51c94b9401c5ea876ec511ae935ac1c52f24802 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 15:29:19 -0800 Subject: [PATCH 34/52] Downgrade to feedback@0.23.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d70c96847..8481bad37 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "dev-live-reload": "0.24.0", "editor-stats": "0.13.0", "exception-reporting": "0.13.0", - "feedback": "0.24.0", + "feedback": "0.23.0", "find-and-replace": "0.81.0", "fuzzy-finder": "0.32.0", "gists": "0.17.0", From 00f30eaf6c50ddbee5e46db94d95010ffac80a1c Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 15:50:48 -0800 Subject: [PATCH 35/52] Make immediate package loading work --- src/atom-package.coffee | 19 +++++++++++++++++-- src/package-manager.coffee | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/atom-package.coffee b/src/atom-package.coffee index b37e5d66d..9d6503da9 100644 --- a/src/atom-package.coffee +++ b/src/atom-package.coffee @@ -60,19 +60,34 @@ class AtomPackage extends Package @grammars = [] @scopedProperties = [] - activate: ({immediate}={}) -> + activate: -> return @activationDeferred.promise if @activationDeferred? @activationDeferred = Q.defer() @measure 'activateTime', => @activateResources() - if @metadata.activationEvents? and not immediate + if @metadata.activationEvents? @subscribeToActivationEvents() else @activateNow() @activationDeferred.promise + # Deprecated + activateSync: ({immediate}={}) -> + @activateResources() + if @metadata.activationEvents? and not immediate + @subscribeToActivationEvents() + else + try + @activateConfig() + @activateStylesheets() + if @requireMainModule() + @mainModule.activate(atom.packages.getPackageState(@name) ? {}) + @mainActivated = true + catch e + console.warn "Failed to activate package named '#{@name}'", e.stack + activateNow: -> try @activateConfig() diff --git a/src/package-manager.coffee b/src/package-manager.coffee index 5cfa58c5e..3523474ea 100644 --- a/src/package-manager.coffee +++ b/src/package-manager.coffee @@ -98,11 +98,12 @@ class PackageManager @activePackages[pack.name] = pack pack + # Deprecated activatePackageSync: (name, options) -> return pack if pack = @getActivePackage(name) if pack = @loadPackage(name) @activePackages[pack.name] = pack - pack.activate(options) + pack.activateSync(options) pack # Private: Deactivate all packages From 282fb66e751cd8e954373adab4140d2ce957c1e5 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 16:30:10 -0800 Subject: [PATCH 36/52] Reject and remove activation deferral on deactivation --- src/atom-package.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/atom-package.coffee b/src/atom-package.coffee index 9d6503da9..c9825055e 100644 --- a/src/atom-package.coffee +++ b/src/atom-package.coffee @@ -185,6 +185,8 @@ class AtomPackage extends Package console.error "Error serializing package '#{@name}'", e.stack deactivate: -> + @activationDeferred.reject() + @activationDeferred = null @unsubscribeFromActivationEvents() @deactivateResources() @deactivateConfig() From f10a70eaf4d12c4e446c6b8b0b5a7df6e7e2782e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 16:32:34 -0800 Subject: [PATCH 37/52] Implement TextMatePackage.activateSync --- src/text-mate-package.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/text-mate-package.coffee b/src/text-mate-package.coffee index 1b0269bc6..99403a4ed 100644 --- a/src/text-mate-package.coffee +++ b/src/text-mate-package.coffee @@ -33,11 +33,11 @@ class TextMatePackage extends Package @metadata = Package.loadMetadata(@path, true) activate: ({sync, immediate}={})-> - if sync or immediate - @loadGrammarsSync() - @loadScopedPropertiesSync() - else - TextMatePackage.addToActivationPromise(this) + TextMatePackage.addToActivationPromise(this) + + activateSync: -> + @loadGrammarsSync() + @loadScopedPropertiesSync() activateConfig: -> # noop From 431688e44cb977c4e967617876acfeaa84608382 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 16:33:28 -0800 Subject: [PATCH 38/52] Remove unused require --- src/text-mate-package.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/text-mate-package.coffee b/src/text-mate-package.coffee index 99403a4ed..eff4d8cd2 100644 --- a/src/text-mate-package.coffee +++ b/src/text-mate-package.coffee @@ -2,7 +2,6 @@ Package = require './package' path = require 'path' _ = require 'underscore-plus' fs = require 'fs-plus' -async = require 'async' Q = require 'q' ### Internal ### From 1a81248c88d0961a4bae585850c3462e185555b0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 17:14:24 -0800 Subject: [PATCH 39/52] :lipstick: Remove extra space --- src/package-manager.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/package-manager.coffee b/src/package-manager.coffee index a28416433..edb376cc0 100644 --- a/src/package-manager.coffee +++ b/src/package-manager.coffee @@ -96,7 +96,7 @@ class PackageManager # Deprecated activatePackageSync: (name, options) -> - return pack if pack = @getActivePackage(name) + return pack if pack = @getActivePackage(name) if pack = @loadPackage(name) @activePackages[pack.name] = pack pack.activateSync(options) From ae7306572b9af18257d3d22060267c2f2d189dc4 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 21:00:50 -0800 Subject: [PATCH 40/52] Guard against empty activationDeferred var --- src/atom-package.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom-package.coffee b/src/atom-package.coffee index f204eec7d..0261b980c 100644 --- a/src/atom-package.coffee +++ b/src/atom-package.coffee @@ -185,7 +185,7 @@ class AtomPackage extends Package console.error "Error serializing package '#{@name}'", e.stack deactivate: -> - @activationDeferred.reject() + @activationDeferred?.reject() @activationDeferred = null @unsubscribeFromActivationEvents() @deactivateResources() From f0197632a353c27d469dd81d999dd5bc53f617f8 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 7 Feb 2014 21:29:37 -0800 Subject: [PATCH 41/52] Upgrade to fuzzy-finder@0.34.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3170e5476..3e93448ad 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "exception-reporting": "0.13.0", "feedback": "0.23.0", "find-and-replace": "0.81.0", - "fuzzy-finder": "0.32.0", + "fuzzy-finder": "0.34.0", "gists": "0.17.0", "git-diff": "0.24.0", "github-sign-in": "0.18.0", From 31a154d7eb1c765cdda18a9cc79bf118f496da25 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Feb 2014 09:16:31 -0800 Subject: [PATCH 42/52] Use subscription to track if disabled packages are observed --- src/package-manager.coffee | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/package-manager.coffee b/src/package-manager.coffee index edb376cc0..7e58d58ee 100644 --- a/src/package-manager.coffee +++ b/src/package-manager.coffee @@ -32,7 +32,6 @@ class PackageManager @loadedPackages = {} @activePackages = {} @packageStates = {} - @observingDisabledPackages = false @packageActivators = [] @registerPackageActivator(this, ['atom', 'textmate']) @@ -129,14 +128,11 @@ class PackageManager @getActivePackage(name)? unobserveDisabledPackages: -> - return unless @observingDisabledPackages - atom.config.unobserve('core.disabledPackages') - @observingDisabledPackages = false + @disabledPackagesSubscription?.off() + @disabledPackagesSubscription = null observeDisabledPackages: -> - return if @observingDisabledPackages - - atom.config.observe 'core.disabledPackages', callNow: false, (disabledPackages, {previous}) => + @disabledPackagesSubscription ?= atom.config.observe 'core.disabledPackages', callNow: false, (disabledPackages, {previous}) => packagesToEnable = _.difference(previous, disabledPackages) packagesToDisable = _.difference(disabledPackages, previous) @@ -144,8 +140,6 @@ class PackageManager @activatePackage(packageName) for packageName in packagesToEnable null - @observingDisabledPackages = true - loadPackages: -> # Ensure atom exports is already in the require cache so the load time # of the first package isn't skewed by being the first to require atom From 33b7c915eb0acd419a279d6470dadd5e8fdf4bfd Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Feb 2014 09:30:59 -0800 Subject: [PATCH 43/52] Upgrade to symbols-view@0.33.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3e93448ad..52262b46f 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "spell-check": "0.23.0", "status-bar": "0.32.0", "styleguide": "0.23.0", - "symbols-view": "0.32.0", + "symbols-view": "0.33.0", "tabs": "0.19.0", "terminal": "0.27.0", "timecop": "0.13.0", From e6d7413af1cd3bb9a01606e7aba1992ca935693b Mon Sep 17 00:00:00 2001 From: probablycorey Date: Mon, 10 Feb 2014 11:21:53 -0800 Subject: [PATCH 44/52] Always call deactivate on loaded packages --- src/package-manager.coffee | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/package-manager.coffee b/src/package-manager.coffee index 7e58d58ee..03052512f 100644 --- a/src/package-manager.coffee +++ b/src/package-manager.coffee @@ -103,17 +103,16 @@ class PackageManager # Deactivate all packages deactivatePackages: -> - @deactivatePackage(pack.name) for pack in @getActivePackages() + @deactivatePackage(pack.name) for pack in @getLoadedPackages() @unobserveDisabledPackages() # Deactivate the package with the given name deactivatePackage: (name) -> - if pack = @getActivePackage(name) + pack = @getLoadedPackage(name) + if @isPackageActive(name) @setPackageState(pack.name, state) if state = pack.serialize?() - pack.deactivate() - delete @activePackages[pack.name] - else - throw new Error("No active package for name '#{name}'") + pack.deactivate() + delete @activePackages[pack.name] # Public: Get an array of all the active packages getActivePackages: -> From 8eee4d87be9781b9b9e799b1cc37a8eb23d2212f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Feb 2014 11:41:08 -0800 Subject: [PATCH 45/52] Guard against missing workspace view --- src/atom-package.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/atom-package.coffee b/src/atom-package.coffee index 0261b980c..b0a187a3a 100644 --- a/src/atom-package.coffee +++ b/src/atom-package.coffee @@ -251,6 +251,8 @@ class AtomPackage extends Package @unsubscribeFromActivationEvents() unsubscribeFromActivationEvents: -> + return unless atom.workspaceView? + if _.isArray(@metadata.activationEvents) atom.workspaceView.off(event, @handleActivationEvent) for event in @metadata.activationEvents else if _.isString(@metadata.activationEvents) From 92b76e61c4f74eee63f76948a4ba2dc2ecaa37e9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Feb 2014 11:46:22 -0800 Subject: [PATCH 46/52] Revert apm change --- vendor/apm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/apm b/vendor/apm index e31303547..ce140e662 160000 --- a/vendor/apm +++ b/vendor/apm @@ -1 +1 @@ -Subproject commit e313035471313623c8de633f0e4de54bf3d859a3 +Subproject commit ce140e66283c07f5837dd999e75580f3757a249a From 0724dd7a7ca8f15cdb3a9e2f83beb4c0e4551e8b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Feb 2014 11:46:58 -0800 Subject: [PATCH 47/52] Remove unused requires --- src/theme-package.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/theme-package.coffee b/src/theme-package.coffee index 1ebbecebb..99cebb077 100644 --- a/src/theme-package.coffee +++ b/src/theme-package.coffee @@ -1,6 +1,4 @@ -Q = require 'q' AtomPackage = require './atom-package' -Package = require './package' ### Internal: Loads and resolves packages. ### From 81e86c14671c6acfc11cd2af7e3946d8b3265409 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Feb 2014 11:48:21 -0800 Subject: [PATCH 48/52] :memo: Remove Internal: comment --- src/theme-package.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/theme-package.coffee b/src/theme-package.coffee index 99cebb077..b0c8bd098 100644 --- a/src/theme-package.coffee +++ b/src/theme-package.coffee @@ -1,10 +1,7 @@ AtomPackage = require './atom-package' -### Internal: Loads and resolves packages. ### - module.exports = class ThemePackage extends AtomPackage - getType: -> 'theme' getStylesheetType: -> 'theme' From ad0bb5098f587a9d2c4d4fb3a95c8ba7f6704586 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Feb 2014 11:50:58 -0800 Subject: [PATCH 49/52] Upgrade to wrap-guide@0.14.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52262b46f..a903c5ccb 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "visual-bell": "0.6.0", "welcome": "0.4.0", "whitespace": "0.11.0", - "wrap-guide": "0.13.0", + "wrap-guide": "0.14.0", "language-c": "0.4.0", "language-clojure": "0.1.0", "language-coffee-script": "0.7.0", From f9f26884686b750cd8efe4e705a3b07065552cbb Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Feb 2014 12:18:15 -0800 Subject: [PATCH 50/52] Upgrade to snippets@0.27.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a903c5ccb..4e17fa78d 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "package-generator": "0.26.0", "release-notes": "0.18.0", "settings-view": "0.71.0", - "snippets": "0.26.0", + "snippets": "0.27.0", "spell-check": "0.23.0", "status-bar": "0.32.0", "styleguide": "0.23.0", From 8425c15cd71b1f8736ee2d61ec99f2df2a4f4478 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 10 Feb 2014 13:06:35 -0800 Subject: [PATCH 51/52] :lipstick: Use Array::filter instead of for/in/when --- src/theme-manager.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/theme-manager.coffee b/src/theme-manager.coffee index 39434f2e1..08ecc0d47 100644 --- a/src/theme-manager.coffee +++ b/src/theme-manager.coffee @@ -95,7 +95,7 @@ class ThemeManager if themePath = @packageManager.resolvePackagePath(themeName) themePaths.push(path.join(themePath, AtomPackage.stylesheetsDir)) - themePath for themePath in themePaths when fs.isDirectorySync(themePath) + themePaths.filter (themePath) -> fs.isDirectorySync(themePath) # Public: Returns the {String} path to the user's stylesheet under ~/.atom getUserStylesheetPath: -> From d415ec9a00960b9b116b502450c0ba0963a20242 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Mon, 10 Feb 2014 13:38:50 -0800 Subject: [PATCH 52/52] Add custom load and activate method to Theme Package --- src/theme-package.coffee | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/theme-package.coffee b/src/theme-package.coffee index b0c8bd098..2d4f611a6 100644 --- a/src/theme-package.coffee +++ b/src/theme-package.coffee @@ -1,3 +1,4 @@ +Q = require 'q' AtomPackage = require './atom-package' module.exports = @@ -11,3 +12,21 @@ class ThemePackage extends AtomPackage disable: -> atom.config.removeAtKeyPath('core.themes', @metadata.name) + + load: -> + @measure 'loadTime', => + try + @metadata ?= Package.loadMetadata(@path) + catch e + console.warn "Failed to load theme named '#{@name}'", e.stack ? e + this + + activate: -> + return @activationDeferred.promise if @activationDeferred? + + @activationDeferred = Q.defer() + @measure 'activateTime', => + @loadStylesheets() + @activateNow() + + @activationDeferred.promise