diff --git a/spec/app/atom-spec.coffee b/spec/app/atom-spec.coffee index dd936a98a..7e317df3c 100644 --- a/spec/app/atom-spec.coffee +++ b/spec/app/atom-spec.coffee @@ -205,6 +205,18 @@ describe "the `atom` global", -> atom.activatePackage('ruby-tmbundle', sync: true) expect(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(syntax, 'addProperties').andCallThrough() + + atom.activatePackage('package-with-preferences-tmbundle') + + waitsFor -> + syntax.addProperties.callCount > 0 + runs -> + expect(syntax.getProperty(['.source.pref'], 'editor.increaseIndentPattern')).toBe '^abc$' + describe ".activatePackageConfig(id)", -> it "calls the optional .activateConfigMenu method on the package's main module", -> pack = atom.activatePackageConfig('package-with-activate-config') diff --git a/spec/fixtures/packages/package-with-preferences-tmbundle/preferences/misc.json b/spec/fixtures/packages/package-with-preferences-tmbundle/preferences/misc.json new file mode 100644 index 000000000..784dd0cbc --- /dev/null +++ b/spec/fixtures/packages/package-with-preferences-tmbundle/preferences/misc.json @@ -0,0 +1,7 @@ +{ + "name": "my preferences", + "scope": "source.pref", + "settings": { + "increaseIndentPattern": "^abc$" + } +} diff --git a/src/app/text-mate-package.coffee b/src/app/text-mate-package.coffee index 64707eac2..6540267f0 100644 --- a/src/app/text-mate-package.coffee +++ b/src/app/text-mate-package.coffee @@ -13,7 +13,10 @@ class TextMatePackage extends Package @getLoadQueue: -> return @loadQueue if @loadQueue - @loadQueue = async.queue (pack, done) -> pack.loadGrammars(done) + @loadQueue = async.queue (pack, done) -> + pack.loadGrammars -> + pack.loadScopedProperties(done) + @loadQueue constructor: -> @@ -44,21 +47,15 @@ class TextMatePackage extends Package loadGrammars: (done) -> fsUtils.isDirectoryAsync @getSyntaxesPath(), (isDirectory) => - return done() unless isDirectory - - fsUtils.listAsync @getSyntaxesPath(), @legalGrammarExtensions, (error, paths) => - if error? - console.log("Error loading grammars of TextMate package '#{@path}':", error.stack, error) - done() - return - - async.waterfall [ - (next) => - async.eachSeries paths, @loadGrammarAtPath, next - (next) => - @loadScopedProperties() - next() - ], done + if isDirectory + fsUtils.listAsync @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() loadGrammarAtPath: (path, done) => TextMateGrammar.load path, (err, grammar) => @@ -105,7 +102,7 @@ class TextMatePackage extends Package for {selector, properties} in @scopedProperties syntax.addProperties(@path, selector, properties) - loadScopedProperties: -> + loadScopedProperties: (callback) -> scopedProperties = [] for grammar in @getGrammars() @@ -124,6 +121,7 @@ class TextMatePackage extends Package if @isActive() for {selector, properties} in @scopedProperties syntax.addProperties(@path, selector, properties) + callback?() @loadTextMatePreferenceObjects(preferenceObjects, done) loadTextMatePreferenceObjects: (preferenceObjects, done) ->