summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Moreau <nathan.moreau@m4x.org>2020-01-29 06:47:40 +0100
committerGitHub <noreply@github.com>2020-01-29 06:47:40 +0100
commit4381a89f6827716c9203b2f9ff0953934c6f0b4b (patch)
treea71fb3de1f91dad16929f3cf454a0d20041f30a1
parent9f3d8cfbd5a454b2096d481970bc6e121f626341 (diff)
downloadrust-mode-4381a89f6827716c9203b2f9ff0953934c6f0b4b.tar.gz
Fix scrolling after rustfmt. (#351)
Co-authored-by: apiraino <apiraino@users.noreply.github.com>
-rw-r--r--rust-mode.el7
1 files changed, 6 insertions, 1 deletions
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))))