# HG changeset patch # User Bram Moolenaar # Date 1582926308 -3600 # Node ID 1671818487705574287b36bba1cf1b22cbbf5268 # Parent 86f834bd45fcfd137aa3289bccf0a9c05c89b72c patch 8.2.0329: popup filter converts 0x80 bytes Commit: https://github.com/vim/vim/commit/ec084d3356cc2a23f2f44707810c38ab590d2e66 Author: Bram Moolenaar Date: Fri Feb 28 22:44:47 2020 +0100 patch 8.2.0329: popup filter converts 0x80 bytes Problem: Popup filter converts 0x80 bytes. Solution: Keep 0x80 bytes as-is. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/5706) diff --git a/src/popupwin.c b/src/popupwin.c --- a/src/popupwin.c +++ b/src/popupwin.c @@ -2999,7 +2999,7 @@ invoke_popup_filter(win_T *wp, int c) // Convert the number to a string, so that the function can use: // if a:c == "\" - buf[special_to_buf(c, mod_mask, TRUE, buf)] = NUL; + buf[special_to_buf(c, mod_mask, FALSE, buf)] = NUL; argv[1].v_type = VAR_STRING; argv[1].vval.v_string = vim_strsave(buf); diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -1409,8 +1409,8 @@ func Test_popup_filter() call setline(1, 'some text') func MyPopupFilter(winid, c) - if a:c == 'e' - let g:eaten = 'e' + if a:c == 'e' || a:c == "\" + let g:eaten = a:c return 1 endif if a:c == '0' @@ -1430,6 +1430,8 @@ func Test_popup_filter() " e is consumed by the filter call feedkeys('e', 'xt') call assert_equal('e', g:eaten) + call feedkeys("\", 'xt') + call assert_equal("\", g:eaten) " 0 is ignored by the filter normal $ @@ -1440,7 +1442,7 @@ func Test_popup_filter() " x closes the popup call feedkeys('x', 'xt') - call assert_equal('e', g:eaten) + call assert_equal("\", g:eaten) call assert_equal(-1, winbufnr(winid)) delfunc MyPopupFilter @@ -3271,4 +3273,26 @@ func Test_popupwin_bufnr() bwipe! endfunc +func Test_popupwin_filter_input_multibyte() + func MyPopupFilter(winid, c) + let g:bytes = range(a:c->strlen())->map({i -> char2nr(a:c[i])}) + return 0 + endfunc + let winid = popup_create('', #{mapping: 0, filter: 'MyPopupFilter'}) + + " UTF-8: E3 80 80, including K_SPECIAL(0x80) + call feedkeys("\u3000", 'xt') + call assert_equal([0xe3, 0x80, 0x80], g:bytes) + + if has('gui') + " UTF-8: E3 80 9B, including CSI(0x9B) + call feedkeys("\u301b", 'xt') + call assert_equal([0xe3, 0x80, 0x9b], g:bytes) + endif + + call popup_clear() + delfunc MyPopupFilter + unlet g:bytes +endfunc + " vim: shiftwidth=2 sts=2 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 329, +/**/ 328, /**/ 327,