Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Multibyte read errors on self-insert



Peter's patch in workers/36496 included this bit of selfinsert():

 #ifdef MULTIBYTE_SUPPORT
-    if (!lastchar_wide_valid)
-       if (getrestchar(lastchar) == WEOF)
-           return 1;
+    DPUTS(!lastchar_wide_valid, "keybuf did not read full wide character");
 #endif

It's trivial to cause this warning to appear starting from zsh -f:

torch% autoload zed
torch% zed -f pickle
pickle() {
}

Now move the cursor to the beginning of the line with the "}" and press
TAB.  In addition to the warning, a newline is inserted instead of a tab.

91: Src/Zle/zle_misc.c:118: keybuf did not read full wide character

This is because selfinsert() was called from expandorcomplete(), so the
special cases in getkeymapcmd() do not apply.  There are a bunch of
places where selfinsert() may be entered indirectly, so I think the
easiest thing is to back out that hunk of the patch even though it is
redundant in the pure self-insert widget case.


diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index 297dc4c..0483f75 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -115,7 +115,10 @@ selfinsert(UNUSED(char **args))
     ZLE_CHAR_T tmp;
 
 #ifdef MULTIBYTE_SUPPORT
-    DPUTS(!lastchar_wide_valid, "keybuf did not read full wide character");
+    /* may be redundant with getkeymapcmd(), but other widgets call here too */
+    if (!lastchar_wide_valid)
+	if (getrestchar(lastchar, NULL, NULL) == WEOF)
+	    return 1;
 #endif
     tmp = LASTFULLCHAR;
     doinsert(&tmp, 1);



Messages sorted by: Reverse Date, Date, Thread, Author