PATCH: count lines in showmsg more correctly
Mikael Magnusson <[email protected]>
| Newsgroups | gmane.comp.shells.zsh.devel |
|---|---|
| Message-ID | <[email protected]> |
If you do this,
wide() { zle -M ${(l:$COLUMNS::a:)} }; zle -N wide; bindkey W wide
then we would move the cursor up one row too many after printing the
message.
The hunks with 1 + are triggered by this (one is MULTIBYTE the other not),
wide() { zle -M ${(l:$COLUMNS::a:)}$'\n'b }; zle -N wide; bindkey W wide
---
Believe it or not, but this one actually didn't happen to me until last week. I have
a paste hook that shows the git commit title using zle -M when pasting a SHA-1 and
one just so happened to be exactly $COLUMNS wide.
Src/Zle/zle_utils.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 4c60a5bb78..ff799369f7 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1335,7 +1335,7 @@ showmsg(char const *msg)
p++;
putc('\n', shout);
- up += 1 + cc / zterm_columns;
+ up += 1 + (cc - 1) / zterm_columns;
cc = 0;
} else {
/*
@@ -1386,7 +1386,7 @@ showmsg(char const *msg)
c = *++p ^ 32;
if(c == '\n') {
putc('\n', shout);
- up += 1 + cc / zterm_columns;
+ up += 1 + (cc - 1) / zterm_columns;
cc = 0;
} else {
char const *n = nicechar(c);
@@ -1395,7 +1395,7 @@ showmsg(char const *msg)
}
}
#endif
- up += cc / zterm_columns;
+ up += (cc - 1) / zterm_columns;
if (clearflag) {
putc('\r', shout);
--
2.38.1