From 57bfd997a509d1fcee12deca89d42839c185fb4a Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Mon, 13 Jul 2015 00:49:29 -0700 Subject: [PATCH] move subtraction by one out of prompt_pure_string_length prompt_pure_string_length is used for calculating the length of the preprompt, but the preprompt doesn't contain a newline, so we shouldn't subtract by one in prompt_pure_string_length. What should happen instead is that when we subtract one from the length when we calculate the number of lines the preprompt occupies. --- pure.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pure.zsh b/pure.zsh index 9b02f81..24c0328 100644 --- a/pure.zsh +++ b/pure.zsh @@ -76,8 +76,7 @@ prompt_pure_preexec() { # string length ignoring ansi escapes prompt_pure_string_length() { - # Subtract one since newline is counted as two characters - echo $(( ${#${(S%%)1//(\%([KF1]|)\{*\}|\%[Bbkf])}} - 1 )) + echo $(( ${#${(S%%)1//(\%([KF1]|)\{*\}|\%[Bbkf])}} )) } prompt_pure_preprompt_render() { @@ -108,7 +107,7 @@ prompt_pure_preprompt_render() { # calculate length of preprompt for redraw purposes local preprompt_length=$(prompt_pure_string_length $preprompt) - local lines=$(( $preprompt_length / $COLUMNS + 1 )) + local lines=$(( ($preprompt_length - 1) / $COLUMNS + 1 )) # disable clearing of line if last char of preprompt is last column of terminal local clr="\e[K"