From 2b7bbb35a714f08308f0bf3b60674bf9005ae7b5 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Tue, 5 May 2015 14:46:18 -0300 Subject: [PATCH] See #317. Use Warning notification, improve message for unsupported lang --- src/beautifiers/index.coffee | 38 ++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 9261622..d60bd46 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -216,6 +216,13 @@ module.exports = class Beautifiers # logger.verbose('flatOptions', flatOptions) return flatOptions + ### + From https://github.com/atom/notifications/blob/01779ade79e7196f1603b8c1fa31716aa4a33911/lib/notification-issue.coffee#L130 + ### + encodeURI: (str) -> + str = encodeURI(str) + str.replace(/#/g, '%23').replace(/;/g, '%3B') + ### ### @@ -226,6 +233,9 @@ module.exports = class Beautifiers _.contains(beautifier.languages, language) ) + ### + + ### beautify: (text, allOptions, grammar, filePath) -> return new Promise((resolve, reject) => logger.info('beautify', text, allOptions, grammar, filePath) @@ -348,8 +358,32 @@ module.exports = class Beautifiers if atom.config.get("atom-beautify.muteUnsupportedLanguageErrors") return resolve(null) else - reject(new Error("Unsupported language for grammar '#{grammar}' with extension '#{fileExtension}'.")) - + repoBugsUrl = pkg.bugs.url + # issueTitle = "Add support for language with grammar '#{grammar}' and extension '#{fileExtension}'" + # issueBody = """ + # ### About My Installation + # **Atom Version**: #{atom.getVersion()} + # **Atom Beautify Version**: #{pkg.version} + # **Platform**: #{process.platform} + # + # ### Example input file: + # ```#{fileExtension} + # #{text} + # ``` + # + # """ + # requestLanguageUrl = "#{repoBugsUrl}/new?title=#{@encodeURI(issueTitle)}&body=#{@encodeURI(issueBody)}" + # detail = "If you would like to request this language be supported please create an issue by clicking request new language support." + title = "Atom Beautify could not find a supported beautifier for this file" + detail = """ + Atom Beautify could not determine a supported beautifier to handle this file with grammar \"#{grammar}\" and extension \"#{fileExtension}\". \ + If you would like to request support for this file and it's language, please create an issue for Atom Beautify at #{repoBugsUrl} + """ + atom?.notifications.addWarning(title, { + detail + dismissable: true + }) + return resolve(null) ) findFileResults: {}