Subject: Completion in empty double-quotes generates error
From: Bart Schaefer <[email-masked]>
To: [email-masked]
Date: Wed, 30 Mar 2016 11:06:52 -0700
List-Id: Zsh Workers List <zsh-workers.zsh.org>

About six years ago, I wrote:
} If I invoke quote-and-complete-word via execute-named-command on an
} empty buffer, I get this:
} 
} schaefer<525> 11: ../../../zsh-4.0/Src/Zle/zle_tricky.c:661: BUG: 0 <= wb <=
} zlemetacs <= we is not true!
} 
} The same error does not occur when invoking it via a direct binding.

Well, now it DOES occur when invoking via direct binding.  The error
message has gotten a bit more informative.

---------------
torch% autoload quote-and-complete-word 
torch% zle -N quote-and-complete-word
torch% bindkey '\t' quote-and-complete-word
torch% ls <TAB>
torch% ls 10: ../../../zsh-5.0/Src/Zle/zle_tricky.c:658: BUG: 0 <= wb (3) <= zlemetacs (2) <= we (3) is not true!
""     ls ""
(listing here)
---------------

The "10:" would seem to imply that the error comes from the first call to
"zle complete-word" in quote-and-complete-word, but if I simplify the
function down to just that I don't get the error.

Further experimentation reveals that starting from a clean "compinit" I can
generate the error by completing inside empty double quotes"

torch% ls ""<backward-char><complete-word>
torch% ls " ../../../zsh-5.0/Src/Zle/zle_tricky.c:658: BUG: 0 <= wb (3) <= zlemetacs (2) <= we (3) is not true!
       ls ""

If there is even one other character inside the quotes before completing, no
error is reported.