branch: elpa/rust-mode
commit 4381a89f6827716c9203b2f9ff0953934c6f0b4b
Author: Nathan Moreau <[email protected]>
Commit: GitHub <[email protected]>
Fix scrolling after rustfmt. (#351)
Co-authored-by: apiraino <[email protected]>
---
rust-mode.el | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/rust-mode.el b/rust-mode.el
index 3d50c2e..84a9355 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1569,7 +1569,12 @@ Return the created process."
(rust--format-get-loc buffer point))
window-loc))))))
(unwind-protect
- (rust--format-call (current-buffer))
+ ;; save and restore window start position
+ ;; after reformatting
+ ;; to avoid the disturbing scrolling
+ (let ((w-start (window-start)))
+ (rust--format-call (current-buffer))
+ (set-window-start (selected-window) w-start))
(dolist (loc buffer-loc)
(let* ((buffer (pop loc))
(pos (rust--format-get-pos buffer (pop loc))))