mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Support preferences registered via a comma-separated scope list
This commit is contained in:
@@ -7,6 +7,9 @@ describe "TextMateBundle", ->
|
||||
expect(TextMateBundle.getPreferenceInScope('source.coffee', 'decreaseIndentPattern')).toBe '^\\s*(\\}|\\]|else|catch|finally)$'
|
||||
expect(TextMateBundle.getPreferenceInScope('source.coffee', 'shellVariables')).toBeDefined()
|
||||
|
||||
it "returns the preference by the given name in the given scope for a scope registered via a comma-separated list of scopes", ->
|
||||
expect(TextMateBundle.getPreferenceInScope('source.objc++', 'shellVariables')).toBeDefined()
|
||||
|
||||
describe ".getPreferencesByScopeSelector()", ->
|
||||
it "logs warning, but does not raise errors if a preference can't be parsed", ->
|
||||
bundlePath = fs.join(require.resolve('fixtures'), "test.tmbundle")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
_ = require 'underscore'
|
||||
fs = require 'fs'
|
||||
plist = require 'plist'
|
||||
$ = require 'jquery'
|
||||
|
||||
TextMateGrammar = require 'text-mate-grammar'
|
||||
|
||||
@@ -23,7 +24,10 @@ class TextMateBundle
|
||||
@bundles.push(bundle)
|
||||
|
||||
for scopeSelector, preferences of bundle.getPreferencesByScopeSelector()
|
||||
@preferencesByScopeSelector[scopeSelector] = preferences
|
||||
if @preferencesByScopeSelector[scopeSelector]?
|
||||
_.extend(@preferencesByScopeSelector[scopeSelector], preferences)
|
||||
else
|
||||
@preferencesByScopeSelector[scopeSelector] = preferences
|
||||
|
||||
for grammar in bundle.grammars
|
||||
@grammars.push(grammar)
|
||||
@@ -91,7 +95,9 @@ class TextMateBundle
|
||||
console.warn "Failed to parse preference at path '#{preferencePath}'", e
|
||||
else
|
||||
{ scope, settings } = data[0]
|
||||
preferencesByScopeSelector[scope] = _.extend(preferencesByScopeSelector[scope] ? {}, settings)
|
||||
for scope in scope.split(',')
|
||||
scope = $.trim(scope)
|
||||
preferencesByScopeSelector[scope] = _.extend(preferencesByScopeSelector[scope] ? {}, settings)
|
||||
|
||||
preferencesByScopeSelector
|
||||
|
||||
@@ -100,4 +106,3 @@ class TextMateBundle
|
||||
|
||||
getPreferencesPath: ->
|
||||
fs.join(@path, "Preferences")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user