summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-07-26 10:20:21 -0400
committerGitHub <noreply@github.com>2016-07-26 10:20:21 -0400
commitba5ff9058546df593ff7d8737fb52b5e92ad1913 (patch)
treee9fbe5b165748dcb439b980ffece433891e4c1fb
parentb3b0f780b1872951874b2ed05eb476ef6e980c09 (diff)
parentcffb950f2063184c23512c7b9305e3244e2cb47c (diff)
downloadrust-mode-ba5ff9058546df593ff7d8737fb52b5e92ad1913.tar.gz
Merge pull request #159 from hotpxl/master
[master] Copy buffer only when format changes.
-rw-r--r--rust-mode.el6
1 files 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 ()