Skip to content

Commit ba5ff90

Browse files
authored
Merge pull request #159 from hotpxl/master
[master] Copy buffer only when format changes.
2 parents b3b0f78 + cffb950 commit ba5ff90

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+
(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)