Preserve the window pos rather than jumping to the top of the file

This inspired by how blacken.el does it:

3bdb26788e/blacken.el (L140)
This commit is contained in:
Hristos N. Triantafillou
2020-05-16 16:34:38 -05:00
parent 0718ca9b09
commit 4ddfc8edce

View File

@@ -52,8 +52,12 @@
(defun gdscript-format-buffer()
"Format the entire current buffer using `gdformat'"
(interactive)
(gdscript-format--format-region
(point-min) (point-max)))
(let ((original-point (point))
(original-window-pos (window-start)))
(gdscript-format--format-region
(point-min) (point-max))
(goto-char original-point)
(set-window-start (selected-window) original-window-pos)))
(provide 'gdscript-format)