Skip to content

Commit 4381a89

Browse files
mookidapiraino
andauthored
Fix scrolling after rustfmt. (#351)
Co-authored-by: apiraino <apiraino@users.noreply.github.com>
1 parent 9f3d8cf commit 4381a89

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rust-mode.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,12 @@ Return the created process."
15691569
(rust--format-get-loc buffer point))
15701570
window-loc))))))
15711571
(unwind-protect
1572-
(rust--format-call (current-buffer))
1572+
;; save and restore window start position
1573+
;; after reformatting
1574+
;; to avoid the disturbing scrolling
1575+
(let ((w-start (window-start)))
1576+
(rust--format-call (current-buffer))
1577+
(set-window-start (selected-window) w-start))
15731578
(dolist (loc buffer-loc)
15741579
(let* ((buffer (pop loc))
15751580
(pos (rust--format-get-pos buffer (pop loc))))

0 commit comments

Comments
 (0)