From: Noam Postavsky Date: Sun, 10 Jun 2018 22:47:27 +0000 (-0400) Subject: Merge from emacs-26 X-Git-Tag: emacs-27.0.90~4884 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=962547791e6ea16b18512e6b933a5317c464da26;p=emacs.git Merge from emacs-26 8a1576cc03 Fix term.el cursor movement at bottom margin (Bug#31690) --- 962547791e6ea16b18512e6b933a5317c464da26 diff --cc lisp/term.el index 9aa4a20e36e,60cd547f93d..121a22e7933 --- a/lisp/term.el +++ b/lisp/term.el @@@ -3298,19 -3381,15 +3298,17 @@@ option is enabled. See `term-set-goto- ;; If the amount to move is before scroll start, move ;; to scroll start. (- term-scroll-start tcr) - (if (>= term-terminal-parameter tcr) + (if (>= scroll-amount tcr) (- tcr) - (- (max 1 term-terminal-parameter)))) t))) + (- (max 1 scroll-amount)))) + t))) ;; \E[B - cursor down (terminfo: cud) ((eq char ?B) - (let ((tcr (term-current-row))) + (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 term-terminal-parameter)) ++ (min (- term-scroll-end tcr) (max 1 scroll-amount)) t)))) ;; \E[C - cursor right (terminfo: cuf, cuf1) ((eq char ?C) diff --cc test/lisp/term-tests.el index 72a9ad1ef74,7fd8d1293dc..ebf48d50a84 --- a/test/lisp/term-tests.el +++ b/test/lisp/term-tests.el @@@ -131,18 -124,27 +131,38 @@@ line6\ 40 12 (list "\eAnSiTc /f" "oo/\n") 'default-directory) "/foo/")))) +(ert-deftest term-line-wrapping-then-motion () + "Make sure we reset the line-wrapping state after moving cursor. +A real-life example is the default zsh prompt which writes spaces +to the end of line (triggering line-wrapping state), and then +sends a carriage return followed by another space to overwrite +the first character of the line." + (let* ((width 10) + (strs (list "x" (make-string (1- width) ?_) + "\r_"))) + (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