From a30dc6251096bc7196c8158fc285089c644994f6 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Fri, 1 May 2015 03:53:25 -0300 Subject: [PATCH] See #282. Fix getLanguages for finding by name and namespace - Was causing "Duplicate option" warnings --- package.json | 1 + src/beautifiers/index.coffee | 5 +++-- src/languages/index.coffee | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b4d788335..8f267d308 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 31191d282..df41e6b95 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -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('.') @@ -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 @@ -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(', ')})" diff --git a/src/languages/index.coffee b/src/languages/index.coffee index 1f2fa084f..f580cea70 100644 --- a/src/languages/index.coffee +++ b/src/languages/index.coffee @@ -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)) ) \ No newline at end of file