branch: elpa/rust-mode
commit ba5ff9058546df593ff7d8737fb52b5e92ad1913
Merge: b3b0f78 cffb950f2
Author: Niko Matsakis <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #159 from hotpxl/master
[master] Copy buffer only when format changes.
---
rust-mode.el | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/rust-mode.el b/rust-mode.el
index 164c95b..6259b48 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1258,8 +1258,10 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
(erase-buffer)
(insert-buffer-substring buf)
(if (zerop (call-process-region (point-min) (point-max) rust-rustfmt-bin t
t nil))
- (progn (copy-to-buffer buf (point-min) (point-max))
- (kill-buffer))
+ (progn
+ (if (not (string= (buffer-string) (with-current-buffer buf
(buffer-string))))
+ (copy-to-buffer buf (point-min) (point-max)))
+ (kill-buffer))
(error "Rustfmt failed, see *rustfmt* buffer for details"))))
(defun rust-format-buffer ()