aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/term.el6
-rw-r--r--test/lisp/term-tests.el20
2 files changed, 22 insertions, 4 deletions
diff --git a/lisp/term.el b/lisp/term.el
index 9aa4a20e36e..121a22e7933 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -3306,11 +3306,9 @@ option is enabled. See `term-set-goto-process-mark'."
3306 ((eq char ?B) 3306 ((eq char ?B)
3307 (let ((tcr (term-current-row)) 3307 (let ((tcr (term-current-row))
3308 (scroll-amount (car params))) 3308 (scroll-amount (car params)))
3309 (unless (= tcr (1- term-scroll-end)) 3309 (unless (>= tcr term-scroll-end)
3310 (term-down 3310 (term-down
3311 (if (> (+ tcr scroll-amount) term-scroll-end) 3311 (min (- term-scroll-end tcr) (max 1 scroll-amount))
3312 (- term-scroll-end 1 tcr)
3313 (max 1 scroll-amount))
3314 t)))) 3312 t))))
3315 ;; \E[C - cursor right (terminfo: cuf, cuf1) 3313 ;; \E[C - cursor right (terminfo: cuf, cuf1)
3316 ((eq char ?C) 3314 ((eq char ?C)
diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el
index 72a9ad1ef74..ebf48d50a84 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -143,6 +143,26 @@ the first character of the line."
143 (should (equal (term-test-screen-from-input width 12 strs) 143 (should (equal (term-test-screen-from-input width 12 strs)
144 (make-string width ?_))))) 144 (make-string width ?_)))))
145 145
146(ert-deftest term-to-margin ()
147 "Test cursor movement at the scroll margin.
148This is a reduced example from GNU nano's initial screen."
149 (let* ((width 10)
150 (x (make-string width ?x))
151 (y (make-string width ?y)))
152 (should (equal (term-test-screen-from-input
153 width 3
154 `("\e[1;3r" ; Setup 3 line scrolling region.
155 "\e[2;1H" ; Move to 2nd last line.
156 ,x ; Fill with 'x'.
157 "\r\e[1B" ; Next line.
158 ,y)) ; Fill with 'y'.
159 (concat "\n" x "\n" y)))
160 ;; Same idea, but moving upwards.
161 (should (equal (term-test-screen-from-input
162 width 3
163 `("\e[1;3r" "\e[2;1H" ,x "\r\e[1A" ,y))
164 (concat y "\n" x)))))
165
146(provide 'term-tests) 166(provide 'term-tests)
147 167
148;;; term-tests.el ends here 168;;; term-tests.el ends here