Subject: bug#30544: 26.0.91; ansi-term duplicates 2 line zsh prompts any time windows change (maybe other times)

From: Noam Postavsky <[email-masked]>
Date: Sun, 01 Apr 2018 22:39:26 -0400

Noam Postavsky <[email-masked]> writes:

> Odd.  I have urxvt here, and it seems to be able to resize both width
> and height without getting any duplicated prompts.  Could it be that zsh
> always repaints the prompt on a resize, but term.el (and iTerm for width
> adjustments) don't put point where zsh is expecting after a resize?

Okay, I edebugged term-emulate-terminal, zsh is sending the correct
escape sequences, the problem is that `term-current-row' is set to 0,
which causes \e[A to be a nop instead of moving the cursor up one row as
it should.

M-x debug-watch RET term-current-row RET reveals that the
term-set-scroll-region call sets term-current-row to 0.  This is
correct, because it does also move point to row 0.  However, after the
call is finished, term-reset-size does (goto-char point) to restore the
original point, but it doesn't reset the cached row accordingly.

So the following fixes it (possibly we should be resetting the current
column as well?).

--- i/lisp/term.el
+++ w/lisp/term.el
@@ -1167,4 +1167,5 @@ term-reset-size
       (setq term-current-column nil)
       (term-set-scroll-region 0 height)
+      (setq term-current-row nil)
       (goto-char point))))