Skip to content

Commit

Permalink
See #282. Fix getLanguages for finding by name and namespace
Browse files Browse the repository at this point in the history
- Was causing "Duplicate option" warnings
  • Loading branch information
Glavin001 committed May 1, 2015
1 parent 9211a03 commit a30dc62
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"temp": "^0.8.0",
"tidy-markdown": "^0.3.2",
"typescript-formatter": "~0.1.4",
"underscore-plus": "^1.6.6",
"yaml-front-matter": "^3.2.3"
},
"activationCommands": {
Expand Down
5 changes: 3 additions & 2 deletions src/beautifiers/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = class Beautifiers
langOptions = {}
for lang in @languages.languages
langOptions[lang.name] ?= {}
options = _.cloneDeep(langOptions[lang.name])
options = langOptions[lang.name]
for field, op of lang.options
if not op.title?
op.title = _plus.uncamelcase(field).split('.')
Expand Down Expand Up @@ -143,6 +143,7 @@ module.exports = class Beautifiers
lang = @languages.getLanguages(name:langName)?[0]
# Use the namespace from language as key prefix
prefix = lang.namespace
# console.log(langName, lang, prefix, ops)
# Iterate over all language options and rename fields
for field, op of ops
# Rename field
Expand All @@ -159,7 +160,7 @@ module.exports = class Beautifiers
# console.log('language options', language, languageOptions, result)
return _.reduce(languageOptions, ((result, optionDef, optionName) ->
# TODO: Add supported beautifiers to option description
# console.log('optionDef', optionDef)
# console.log('optionDef', optionDef, optionName)
if optionDef.beautifiers.length > 0
# optionDef.title = "#{optionDef.title} - Supported by #{optionDef.beautifiers.join(', ')}"
optionDef.description = "#{optionDef.description} (Supported by #{optionDef.beautifiers.join(', ')})"
Expand Down
6 changes: 3 additions & 3 deletions src/languages/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ module.exports = class Languages
Get language for grammar and extension
###
getLanguages: ({name, namespace, grammar, extension}) ->
# console.log(grammar, extension, @languages)
# console.log('getLanguages', name, namespace, grammar, extension, @languages)
_.union(
_.filter(@languages, (language) -> _.contains(language.name, name))
_.filter(@languages, (language) -> _.contains(language.namespace, namespace))
_.filter(@languages, (language) -> _.isEqual(language.name, name))
_.filter(@languages, (language) -> _.isEqual(language.namespace, namespace))
_.filter(@languages, (language) -> _.contains(language.grammars, grammar))
_.filter(@languages, (language) -> _.contains(language.extensions, extension))
)

0 comments on commit a30dc62

Please sign in to comment.