Skip to content

Commit d98199e

Browse files
swillnerproofit404
authored andcommitted
Only overwrite buffer when black had changed the formatting (#7)
1 parent 65b1f91 commit d98199e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

blacken.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ Show black output, if black exit abnormally and DISPLAY is t."
102102
(condition-case err
103103
(if (not (zerop (blacken-call-bin original-buffer tmpbuf errbuf)))
104104
(error "Black failed, see %s buffer for details" (buffer-name errbuf))
105-
(with-current-buffer tmpbuf
106-
(copy-to-buffer original-buffer (point-min) (point-max)))
105+
(unless (eq (compare-buffer-substrings tmpbuf nil nil original-buffer nil nil) 0)
106+
(with-current-buffer tmpbuf
107+
(copy-to-buffer original-buffer (point-min) (point-max))))
107108
(mapc 'kill-buffer (list tmpbuf errbuf))
108109
(goto-char original-point)
109110
(set-window-start (selected-window) original-window-pos))

0 commit comments

Comments
 (0)