b42efeb87ebdcb89510b8ffbcf210494f194109e

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Switch off line wrapping in case dots occupy extra line

This commit uses the (hopefully) standard rmam and smam escape sequences
which toggle off and on line wrapping respectively.

This is so that extra dots that don't fit the current line won't be
displayed in the next line, which would in turn make the shell
display a new prompt on the next line after the dots are hidden.

I've added a check for $terminfo rmam and smam values to be sure we have
them before printing them out.

If this commit breaks something post an issue with your terminal
emulator and $TERM value and we'll figure out what went wrong.

Diff

 1diff --git a/lib/completion.zsh b/lib/completion.zsh
 2index 81250d9e17c56c786ba73c2b88676aabf8d33b50..f5b29247127543f4aec6ffec6bdb4b29bcdd9de1 100644
 3--- a/lib/completion.zsh
 4+++ b/lib/completion.zsh
 5@@ -60,7 +60,11 @@ zstyle '*' single-ignored show
 6 
 7 if [[ $COMPLETION_WAITING_DOTS = true ]]; then
 8   expand-or-complete-with-dots() {
 9+    # toggle line-wrapping off and back on again
10+    [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
11     print -Pn "%{%F{red}......%f%}"
12+    [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
13+
14     zle expand-or-complete
15     zle redisplay
16   }