To: vim_dev@googlegroups.com Subject: Patch 8.2.0812 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0812 Problem: mapset() does not properly handle <> notation. Solution: Convert <> codes. (closes #6116) Files: src/map.c, src/testdir/test_maparg.vim *** ../vim-8.2.0811/src/map.c 2020-05-22 13:38:15.606498510 +0200 --- src/map.c 2020-05-22 19:47:17.196385407 +0200 *************** *** 2269,2274 **** --- 2269,2276 ---- dict_T *d; char_u *lhs; char_u *rhs; + char_u *orig_rhs; + char_u *arg_buf = NULL; int noremap; int expr; int silent; *************** *** 2304,2309 **** --- 2306,2314 ---- emsg(_("E99: rhs entry missing in mapset() dict argument")); return; } + orig_rhs = rhs; + rhs = replace_termcodes(rhs, &arg_buf, + REPTERM_DO_LT | REPTERM_SPECIAL, NULL); noremap = dict_get_number(d, (char_u *)"noremap") ? REMAP_NONE: 0; if (dict_get_number(d, (char_u *)"script") != 0) *************** *** 2330,2338 **** keys = replace_termcodes(lhs, &keys_buf, REPTERM_FROM_PART | REPTERM_DO_LT, NULL); ! (void)map_add(map_table, abbr_table, keys, rhs, rhs, noremap, nowait, silent, mode, is_abbr, expr, sid, lnum, simplified); vim_free(keys_buf); } #endif --- 2335,2344 ---- keys = replace_termcodes(lhs, &keys_buf, REPTERM_FROM_PART | REPTERM_DO_LT, NULL); ! (void)map_add(map_table, abbr_table, keys, rhs, orig_rhs, noremap, nowait, silent, mode, is_abbr, expr, sid, lnum, simplified); vim_free(keys_buf); + vim_free(arg_buf); } #endif *** ../vim-8.2.0811/src/testdir/test_maparg.vim 2020-05-22 13:09:55.320226061 +0200 --- src/testdir/test_maparg.vim 2020-05-22 20:00:19.320652928 +0200 *************** *** 6,12 **** return str2nr(matchstr(expand(''), '\zs\d\+\ze_SID$')) endfunc ! funct Test_maparg() new set cpo-=< set encoding=utf8 --- 6,12 ---- return str2nr(matchstr(expand(''), '\zs\d\+\ze_SID$')) endfunc ! func Test_maparg() new set cpo-=< set encoding=utf8 *************** *** 156,161 **** --- 156,228 ---- func Test_mapset() call One_mapset_test('K') call One_mapset_test('') + + " Check <> key conversion + new + inoremap K onex + call feedkeys("iK\", 'xt') + call assert_equal('onxe', getline(1)) + + let orig = maparg('K', 'i', 0, 1) + call assert_equal('K', orig.lhs) + call assert_equal('onex', orig.rhs) + call assert_equal('i', orig.mode) + + iunmap K + let d = maparg('K', 'i', 0, 1) + call assert_equal({}, d) + + call mapset('i', 0, orig) + call feedkeys("SK\", 'xt') + call assert_equal('onxe', getline(1)) + + iunmap K + + " Test literal using a backslash + let cpo_save = &cpo + set cpo-=B + inoremap K one\two + call feedkeys("SK\", 'xt') + call assert_equal('onetwo', getline(1)) + + let orig = maparg('K', 'i', 0, 1) + call assert_equal('K', orig.lhs) + call assert_equal('one\two', orig.rhs) + call assert_equal('i', orig.mode) + + iunmap K + let d = maparg('K', 'i', 0, 1) + call assert_equal({}, d) + + call mapset('i', 0, orig) + call feedkeys("SK\", 'xt') + call assert_equal('onetwo', getline(1)) + + iunmap K + let &cpo = cpo_save + + " Test literal using CTRL-V + inoremap K onetwo + call feedkeys("SK\", 'xt') + call assert_equal('onetwo', getline(1)) + + let orig = maparg('K', 'i', 0, 1) + call assert_equal('K', orig.lhs) + call assert_equal("one\x16two", orig.rhs) + call assert_equal('i', orig.mode) + + iunmap K + let d = maparg('K', 'i', 0, 1) + call assert_equal({}, d) + + call mapset('i', 0, orig) + call feedkeys("SK\", 'xt') + call assert_equal('onetwo', getline(1)) + + iunmap K + let &cpo = cpo_save + + bwipe! endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0811/src/version.c 2020-05-22 14:44:23.301661908 +0200 --- src/version.c 2020-05-22 19:42:44.073770419 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 812, /**/ -- hundred-and-one symptoms of being an internet addict: 163. You go outside for the fresh air (at -30 degrees) but open the window first to hear new mail arrive. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///