Skip to content

Commit 6886300

Browse files
committed
[master] Copy buffer only when format changes.
1 parent 0cf2bc3 commit 6886300

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

rust-mode.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,8 +1258,10 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
12581258
(erase-buffer)
12591259
(insert-buffer-substring buf)
12601260
(if (zerop (call-process-region (point-min) (point-max) rust-rustfmt-bin t t nil))
1261-
(progn (copy-to-buffer buf (point-min) (point-max))
1262-
(kill-buffer))
1261+
(progn
1262+
(if (not (string= (buffer-string) (with-current-buffer buf (buffer-string))))
1263+
(progn (copy-to-buffer buf (point-min) (point-max))))
1264+
(kill-buffer))
12631265
(error "Rustfmt failed, see *rustfmt* buffer for details"))))
12641266

12651267
(defun rust-format-buffer ()

0 commit comments

Comments
 (0)