--- vile-9.8x+/map.c 2022-12-23 00:32:02.000000000 +0000 +++ vile-9.8y/map.c 2023-01-13 08:51:24.000000000 +0000 @@ -923,6 +926,18 @@ } do { + /* + * This is a workaround for an ambiguity between the different return + * values from mapgetc(), on entry to this function: + * - If infloopcount is zero, mapgetc() has just called tgetc(), which + * in turn called sysmapped_c(), and then term.getc(). That pointer + * is initialized to vl_mb_getch(), which will decode UTF-8 into a + * Unicode value. + * - If infloopcount is nonzero, the function returns a byte (of UTF-8), + * which must be decoded later in this function. + */ + int full_c = (infloopcount == 0); /* tgetc returned full char? */ + (void) itb_init(&mappedchars, esc_c); matched = maplookup(c, @@ -949,7 +966,7 @@ c = mapgetc(); #if OPT_MULTIBYTE - if (vl_encoding >= enc_UTF8 && b_is_utfXX(curbp)) { + if (remap && !full_c && (vl_encoding >= enc_UTF8 && b_is_utfXX(curbp))) { char save[MAX_UTF8]; int have = 0; int need = 9;