From a0a3e88480b70e3057b34f818df209ab9dc8ac84 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Mon, 15 Feb 2016 18:48:09 +0200 Subject: [PATCH] Use zle reset-prompt to restore cursor instead of relying on ansi codes This fixes #191 and can be considered a more robust method of restoring cursor position. --- pure.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pure.zsh b/pure.zsh index 268bbff6..d1de2200 100644 --- a/pure.zsh +++ b/pure.zsh @@ -177,9 +177,6 @@ prompt_pure_preprompt_render() { elif (( last_lines < lines )); then # move cursor using newlines because ansi cursor movement can't push the cursor beyond the last line printf $'\n'%.0s {1..$(( lines - last_lines ))} - - # redraw the prompt since it has been moved by print - zle && zle .reset-prompt fi # disable clearing of line if last char of preprompt is last column of terminal @@ -187,7 +184,10 @@ prompt_pure_preprompt_render() { (( COLUMNS * lines == preprompt_length )) && clr= # modify previous preprompt - print -Pn "\e7${clr_prev_preprompt}\e[${lines}A\e[1G${preprompt}${clr}\e8" + print -Pn "${clr_prev_preprompt}\e[${lines}A\e[${COLUMNS}D${preprompt}${clr}\n" + + # redraw prompt (also resets cursor position) + zle && zle .reset-prompt fi # store previous preprompt for comparison