From 40f1fe3c8dcfad55312a57b41ace3c13f113893d Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Fri, 16 Jun 2017 20:33:19 -0300 Subject: [PATCH] Fixes #1361. Add file extension to temporary files for Uncrustify beautifier --- src/beautifiers/index.coffee | 3 ++- src/beautifiers/uncrustify/index.coffee | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 92acc76..e16d1a7 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -282,6 +282,7 @@ module.exports = class Beautifiers extends EventEmitter logger.verbose(allOptions) language ?= @getLanguage(grammar, filePath) + fileExtension = @getExtension(filePath) # Check if unsupported language if !language @@ -343,6 +344,7 @@ module.exports = class Beautifiers extends EventEmitter context = filePath: filePath + fileExtension: fileExtension startTime = new Date() beautifier.loadExecutables() @@ -405,7 +407,6 @@ module.exports = class Beautifiers extends EventEmitter if atom.config.get("atom-beautify.general.muteUnsupportedLanguageErrors") return resolve( null ) else - fileExtension = @getExtension(filePath) repoBugsUrl = pkg.bugs.url title = "Atom Beautify could not find a supported beautifier for this file" detail = """ diff --git a/src/beautifiers/uncrustify/index.coffee b/src/beautifiers/uncrustify/index.coffee index ffaa46a..e2c878c 100644 --- a/src/beautifiers/uncrustify/index.coffee +++ b/src/beautifiers/uncrustify/index.coffee @@ -46,7 +46,9 @@ module.exports = class Uncrustify extends Beautifier Arduino: true } - beautify: (text, language, options) -> + beautify: (text, language, options, context) -> + fileExtension = context.fileExtension + uncrustify = @exe("uncrustify") # console.log('uncrustify.beautify', language, options) return new @Promise((resolve, reject) -> @@ -99,9 +101,9 @@ module.exports = class Uncrustify extends Beautifier "-c" configPath "-f" - @tempFile("input", text) + @tempFile("input", text, fileExtension and ".#{fileExtension}") "-o" - outputFile = @tempFile("output", text) + outputFile = @tempFile("output", text, fileExtension and ".#{fileExtension}") "-l" lang ])