diff options
| author | brotzeit <brotzeitmacher@gmail.com> | 2022-01-07 11:11:21 +0100 |
|---|---|---|
| committer | brotzeit <brotzeitmacher@gmail.com> | 2022-01-07 11:11:21 +0100 |
| commit | ad674a1d43a7ffefd3dba33599c6aa5f49d70e43 (patch) | |
| tree | 0d089b27ce583d85bae28f89f6eb50baa260c57a /rust-rustfmt.el | |
| parent | b173b3aed726b583d6c82d4cb0743336a544cf27 (diff) | |
| download | rust-mode-ad674a1d43a7ffefd3dba33599c6aa5f49d70e43.tar.gz | |
save excursion when formatting
close #392
Diffstat (limited to 'rust-rustfmt.el')
| -rw-r--r-- | rust-rustfmt.el | 8 |
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." |
