To: vim_dev@googlegroups.com Subject: Patch 9.0.0341 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0341 Problem: mapset() does not restore mapping properly. Solution: Use an empty string for . (closes #11022) Files: src/map.c, src/testdir/test_map_functions.vim *** ../vim-9.0.0340/src/map.c 2022-08-30 19:48:17.202760217 +0100 --- src/map.c 2022-08-31 16:31:38.132454410 +0100 *************** *** 2658,2664 **** return; } orig_rhs = rhs; ! rhs = replace_termcodes(rhs, &arg_buf, REPTERM_DO_LT | REPTERM_SPECIAL, NULL); noremap = dict_get_number(d, "noremap") ? REMAP_NONE: 0; --- 2658,2667 ---- return; } orig_rhs = rhs; ! if (STRICMP(rhs, "") == 0) // "" means nothing ! rhs = (char_u *)""; ! else ! rhs = replace_termcodes(rhs, &arg_buf, REPTERM_DO_LT | REPTERM_SPECIAL, NULL); noremap = dict_get_number(d, "noremap") ? REMAP_NONE: 0; *** ../vim-9.0.0340/src/testdir/test_map_functions.vim 2022-08-30 19:48:17.206760205 +0100 --- src/testdir/test_map_functions.vim 2022-08-31 16:31:38.132454410 +0100 *************** *** 183,193 **** call assert_equal("abcd", getline(1)) endfunc ! func One_mapset_test(keys) ! exe 'nnoremap ' .. a:keys .. ' original' let orig = maparg(a:keys, 'n', 0, 1) call assert_equal(a:keys, orig.lhs) ! call assert_equal('original', orig.rhs) call assert_equal('n', orig.mode) exe 'nunmap ' .. a:keys --- 183,193 ---- call assert_equal("abcd", getline(1)) endfunc ! func One_mapset_test(keys, rhs) ! exe 'nnoremap ' .. a:keys .. ' ' .. a:rhs let orig = maparg(a:keys, 'n', 0, 1) call assert_equal(a:keys, orig.lhs) ! call assert_equal(a:rhs, orig.rhs) call assert_equal('n', orig.mode) exe 'nunmap ' .. a:keys *************** *** 197,211 **** call mapset('n', 0, orig) let d = maparg(a:keys, 'n', 0, 1) call assert_equal(a:keys, d.lhs) ! call assert_equal('original', d.rhs) call assert_equal('n', d.mode) exe 'nunmap ' .. a:keys endfunc func Test_mapset() ! call One_mapset_test('K') ! call One_mapset_test('') " Check <> key conversion new --- 197,212 ---- call mapset('n', 0, orig) let d = maparg(a:keys, 'n', 0, 1) call assert_equal(a:keys, d.lhs) ! call assert_equal(a:rhs, d.rhs) call assert_equal('n', d.mode) exe 'nunmap ' .. a:keys endfunc func Test_mapset() ! call One_mapset_test('K', 'original') ! call One_mapset_test('', 'original') ! call One_mapset_test('', 'Nop>') " Check <> key conversion new *************** *** 228,233 **** --- 229,254 ---- iunmap K + " Test that is restored properly + inoremap K + call feedkeys("SK\", 'xt') + call assert_equal('', getline(1)) + + let orig = maparg('K', 'i', 0, 1) + call assert_equal('K', orig.lhs) + call assert_equal('', orig.rhs) + call assert_equal('i', orig.mode) + + inoremap K foo + call feedkeys("SK\", 'xt') + call assert_equal('foo', getline(1)) + + call mapset('i', 0, orig) + call feedkeys("SK\", 'xt') + call assert_equal('', getline(1)) + + iunmap K + " Test literal using a backslash let cpo_save = &cpo set cpo-=B *** ../vim-9.0.0340/src/version.c 2022-08-31 14:46:07.915016883 +0100 --- src/version.c 2022-08-31 16:38:33.331170737 +0100 *************** *** 709,710 **** --- 709,712 ---- { /* Add new patch number below this line */ + /**/ + 341, /**/ -- Bad programs can be written in any language. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///