summaryrefslogtreecommitdiff
path: root/rust-rustfmt.el
diff options
context:
space:
mode:
Diffstat (limited to 'rust-rustfmt.el')
-rw-r--r--rust-rustfmt.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/rust-rustfmt.el b/rust-rustfmt.el
index 0690b84..530abaa 100644
--- a/rust-rustfmt.el
+++ b/rust-rustfmt.el
@@ -331,9 +331,11 @@ Return the created process."
;; If emacs version >= 26.2, we can use replace-buffer-contents to
;; preserve location and markers in buffer, otherwise we can try to
;; save locations as best we can, though we still lose markers.
- (if (version<= "26.2" emacs-version)
- (rust--format-buffer-using-replace-buffer-contents)
- (rust--format-buffer-saving-position-manually)))
+ (save-excursion
+ (save-window-excursion
+ (if (version<= "26.2" emacs-version)
+ (rust--format-buffer-using-replace-buffer-contents)
+ (rust--format-buffer-saving-position-manually)))))
(defun rust-enable-format-on-save ()
"Enable formatting using rustfmt when saving buffer."