aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/term.el11
-rw-r--r--test/lisp/term-tests.el12
2 files changed, 20 insertions, 3 deletions
diff --git a/lisp/term.el b/lisp/term.el
index 93da33ea5b0..91eab771cf0 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -2891,9 +2891,11 @@ See `term-prompt-regexp'."
2891 ;; If the last char was written in last column, 2891 ;; If the last char was written in last column,
2892 ;; back up one column, but remember we did so. 2892 ;; back up one column, but remember we did so.
2893 ;; Thus we emulate xterm/vt100-style line-wrapping. 2893 ;; Thus we emulate xterm/vt100-style line-wrapping.
2894 (cond ((eq (term-current-column) term-width) 2894 (when (eq (term-current-column) term-width)
2895 (term-move-columns -1) 2895 (term-move-columns -1)
2896 (setq term-do-line-wrapping t))) 2896 ;; We check after ctrl sequence handling if point
2897 ;; was moved (and leave line-wrapping state if so).
2898 (setq term-do-line-wrapping (point)))
2897 (setq term-current-column nil) 2899 (setq term-current-column nil)
2898 (setq i funny)) 2900 (setq i funny))
2899 (pcase-exhaustive (and (<= ctl-end str-length) (aref str i)) 2901 (pcase-exhaustive (and (<= ctl-end str-length) (aref str i))
@@ -2993,6 +2995,9 @@ See `term-prompt-regexp'."
2993 (substring str i ctl-end))))) 2995 (substring str i ctl-end)))))
2994 ;; Ignore NUL, Shift Out, Shift In. 2996 ;; Ignore NUL, Shift Out, Shift In.
2995 ((or ?\0 #xE #xF 'nil) nil)) 2997 ((or ?\0 #xE #xF 'nil) nil))
2998 ;; Leave line-wrapping state if point was moved.
2999 (unless (eq term-do-line-wrapping (point))
3000 (setq term-do-line-wrapping nil))
2996 (if (term-handling-pager) 3001 (if (term-handling-pager)
2997 (progn 3002 (progn
2998 ;; Finish stuff to get ready to handle PAGER. 3003 ;; Finish stuff to get ready to handle PAGER.
diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el
index 234dfa1f0d5..8aaa61a210b 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -124,6 +124,18 @@ line6\r
124 40 12 (list "\eAnSiTc /f" "oo/\n") 'default-directory) 124 40 12 (list "\eAnSiTc /f" "oo/\n") 'default-directory)
125 "/foo/")))) 125 "/foo/"))))
126 126
127(ert-deftest term-line-wrapping-then-motion ()
128 "Make sure we reset the line-wrapping state after moving cursor.
129A real-life example is the default zsh prompt which writes spaces
130to the end of line (triggering line-wrapping state), and then
131sends a carriage return followed by another space to overwrite
132the first character of the line."
133 (let* ((width 10)
134 (strs (list "x" (make-string (1- width) ?_)
135 "\r_")))
136 (should (equal (term-test-screen-from-input width 12 strs)
137 (make-string width ?_)))))
138
127(provide 'term-tests) 139(provide 'term-tests)
128 140
129;;; term-tests.el ends here 141;;; term-tests.el ends here