Skip to content

Commit 0e7f904

Browse files
committed
Preserve column position when scrolling in copy mode
ghostel-copy-mode-scroll-up and ghostel-copy-mode-scroll-down were moving point to end-of-line after redraw. Save and restore the column, matching the pattern already used in copy-mode-previous/next-line.
1 parent d07f509 commit 0e7f904

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

ghostel.el

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,24 +1036,28 @@ pasted using bracketed paste."
10361036
(defun ghostel-copy-mode-scroll-up ()
10371037
"Scroll the terminal viewport up by a page in copy mode."
10381038
(interactive)
1039-
(if ghostel--copy-mode-full-buffer
1040-
(scroll-down-command)
1041-
(when ghostel--term
1042-
(let ((height (count-lines (point-min) (point-max))))
1043-
(ghostel--scroll ghostel--term (- 2 height))
1044-
(let ((inhibit-read-only t))
1045-
(ghostel--redraw ghostel--term ghostel-full-redraw))))))
1039+
(let ((col (current-column)))
1040+
(if ghostel--copy-mode-full-buffer
1041+
(scroll-down-command)
1042+
(when ghostel--term
1043+
(let ((height (count-lines (point-min) (point-max))))
1044+
(ghostel--scroll ghostel--term (- 2 height))
1045+
(let ((inhibit-read-only t))
1046+
(ghostel--redraw ghostel--term ghostel-full-redraw)))))
1047+
(move-to-column col)))
10461048

10471049
(defun ghostel-copy-mode-scroll-down ()
10481050
"Scroll the terminal viewport down by a page in copy mode."
10491051
(interactive)
1050-
(if ghostel--copy-mode-full-buffer
1051-
(scroll-up-command)
1052-
(when ghostel--term
1053-
(let ((height (count-lines (point-min) (point-max))))
1054-
(ghostel--scroll ghostel--term (- height 2))
1055-
(let ((inhibit-read-only t))
1056-
(ghostel--redraw ghostel--term ghostel-full-redraw))))))
1052+
(let ((col (current-column)))
1053+
(if ghostel--copy-mode-full-buffer
1054+
(scroll-up-command)
1055+
(when ghostel--term
1056+
(let ((height (count-lines (point-min) (point-max))))
1057+
(ghostel--scroll ghostel--term (- height 2))
1058+
(let ((inhibit-read-only t))
1059+
(ghostel--redraw ghostel--term ghostel-full-redraw)))))
1060+
(move-to-column col)))
10571061

10581062
(defun ghostel-copy-mode-previous-line ()
10591063
"Move to the previous line, scrolling the viewport if at the top."

0 commit comments

Comments
 (0)