Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: count lines in showmsg more correctly
- X-seq: zsh-workers 54686
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: count lines in showmsg more correctly
- Date: Sat, 6 Jun 2026 04:19:43 +0200
- Archived-at: <https://zsh.org/workers/54686>
- List-id: <zsh-workers.zsh.org>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author