diff --git a/CHANGELOG.md b/CHANGELOG.md index e81d6e7..bcf1458 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ The format is based on [Keep a Changelog]. fixes issues with formatters that behave differently when receiving input on stdin versus being run on a tty ([#119]). +### Bugs fixed +* When a formatter has a bug and fails to return anything on stdout + (e.g. scalafmt), do not erase the buffer ([#116]). + ### Formatters * [bean-format](https://github.com/beancount/beancount) for Beancount ([#101]). @@ -21,6 +25,7 @@ The format is based on [Keep a Changelog]. [#105]: https://github.com/radian-software/apheleia/pull/105 [#109]: https://github.com/radian-software/apheleia/issues/109 [#110]: https://github.com/radian-software/apheleia/pull/110 +[#116]: https://github.com/radian-software/apheleia/pull/116 [#119]: https://github.com/radian-software/apheleia/pull/119 ## 3.0 (released 2022-06-01) diff --git a/apheleia.el b/apheleia.el index 37d6c89..332499e 100644 --- a/apheleia.el +++ b/apheleia.el @@ -1034,13 +1034,14 @@ function: %s" command))) buffer remote (lambda (stdout) - (if (cdr formatters) - ;; Forward current stdout to remaining formatters, passing along - ;; the current callback and using the current formatters output - ;; as stdin. - (apheleia--run-formatters - (cdr formatters) buffer remote callback stdout) - (funcall callback stdout))) + (unless (string-empty-p (with-current-buffer stdout (buffer-string))) + (if (cdr formatters) + ;; Forward current stdout to remaining formatters, passing along + ;; the current callback and using the current formatters output + ;; as stdin. + (apheleia--run-formatters + (cdr formatters) buffer remote callback stdout) + (funcall callback stdout)))) stdin (car formatters))))