[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9625477 5/5: Merge from emacs-26
From: |
Noam Postavsky |
Subject: |
[Emacs-diffs] master 9625477 5/5: Merge from emacs-26 |
Date: |
Sun, 10 Jun 2018 19:03:41 -0400 (EDT) |
branch: master
commit 962547791e6ea16b18512e6b933a5317c464da26
Merge: eaeb69c 8a1576c
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Merge from emacs-26
8a1576cc03 Fix term.el cursor movement at bottom margin (Bug#31690)
---
lisp/term.el | 6 ++----
test/lisp/term-tests.el | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/lisp/term.el b/lisp/term.el
index 9aa4a20..121a22e 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -3306,11 +3306,9 @@ option is enabled. See `term-set-goto-process-mark'."
((eq char ?B)
(let ((tcr (term-current-row))
(scroll-amount (car params)))
- (unless (= tcr (1- term-scroll-end))
+ (unless (>= tcr term-scroll-end)
(term-down
- (if (> (+ tcr scroll-amount) term-scroll-end)
- (- term-scroll-end 1 tcr)
- (max 1 scroll-amount))
+ (min (- term-scroll-end tcr) (max 1 scroll-amount))
t))))
;; \E[C - cursor right (terminfo: cuf, cuf1)
((eq char ?C)
diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el
index 72a9ad1..ebf48d5 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -143,6 +143,26 @@ the first character of the line."
(should (equal (term-test-screen-from-input width 12 strs)
(make-string width ?_)))))
+(ert-deftest term-to-margin ()
+ "Test cursor movement at the scroll margin.
+This is a reduced example from GNU nano's initial screen."
+ (let* ((width 10)
+ (x (make-string width ?x))
+ (y (make-string width ?y)))
+ (should (equal (term-test-screen-from-input
+ width 3
+ `("\e[1;3r" ; Setup 3 line scrolling region.
+ "\e[2;1H" ; Move to 2nd last line.
+ ,x ; Fill with 'x'.
+ "\r\e[1B" ; Next line.
+ ,y)) ; Fill with 'y'.
+ (concat "\n" x "\n" y)))
+ ;; Same idea, but moving upwards.
+ (should (equal (term-test-screen-from-input
+ width 3
+ `("\e[1;3r" "\e[2;1H" ,x "\r\e[1A" ,y))
+ (concat y "\n" x)))))
+
(provide 'term-tests)
;;; term-tests.el ends here