mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Always load bundle preferences
Previously the scoped properties would not load if there weren't any grammars in the bundle or if listing the grammars directory failed. Closes #570
This commit is contained in:
@@ -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')
|
||||
|
||||
7
spec/fixtures/packages/package-with-preferences-tmbundle/preferences/misc.json
vendored
Normal file
7
spec/fixtures/packages/package-with-preferences-tmbundle/preferences/misc.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "my preferences",
|
||||
"scope": "source.pref",
|
||||
"settings": {
|
||||
"increaseIndentPattern": "^abc$"
|
||||
}
|
||||
}
|
||||
@@ -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) ->
|
||||
|
||||
Reference in New Issue
Block a user