See #282, #284. Move language options out of option of type `object`

See Atom Settings-View bug:
https://github.com/atom/settings-view/issues/386#issuecomment-98379708
This commit is contained in:
Glavin Wiechert 2015-05-02 14:06:50 -03:00
parent a2262619ad
commit 48af4a3ff6
1 changed files with 20 additions and 25 deletions

View File

@ -185,32 +185,27 @@ module.exports = class Beautifiers
), {})
# Generate Language configurations
langConfigs = {}
# Process all languages
# console.log('languages', languages)
for langName, lang of languages
# console.log(langName, lang)
name = lang.name
beautifiers = lang.beautifiers
langConfigs[name] = {
type: 'object'
properties:
disabled:
optionName = "language_#{lang.namespace}"
# Add Language configurations
flatOptions["#{optionName}_disabled"] = {
title: "Language Config - #{name} - Disable Beautifying Language"
type: 'boolean'
default: false
description: "Disable #{name} Beautification"
default_beautifier:
}
flatOptions["#{optionName}_default_beautifier"] = {
title: "Language Config - #{name} - Default Beautifier"
type: 'string'
default: beautifiers[0]
description: "Default Beautifier to be used for #{name}"
enum: _.uniq(beautifiers)
}
# Add Language configurations
flatOptions.languages = {
type: 'object'
properties: langConfigs
}
# console.log('flatOptions', flatOptions)
return flatOptions
###
@ -238,12 +233,13 @@ module.exports = class Beautifiers
language = languages[0]
# Get language config
langConfig = atom.config.get("atom-beautify.languages")?[language.name]
langDisabled = atom.config.get("atom-beautify.language_#{language.namespace}_disabled")
preferredBeautifierName = atom.config.get("atom-beautify.language_#{language.namespace}_default_beautifier")
# Beautify!
unsupportedGrammar = false
# Check if Language is disabled
if langConfig?.disabled
if langDisabled
return resolve(null)
# Options for Language
@ -264,7 +260,6 @@ module.exports = class Beautifiers
unsupportedGrammar = true
else
# Select beautifier from language config preferences
preferredBeautifierName = langConfig.default_beautifier
beautifier = _.find(beautifiers, (beautifier) ->
beautifier.name is preferredBeautifierName
) or beautifiers[0]