To: vim_dev@googlegroups.com Subject: Patch 8.2.4498 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4498 Problem: Using with "noremap" does not work. Solution: Always remap . (closes #9879, closes #9789) Files: runtime/doc/map.txt, src/getchar.c, src/testdir/test_mapping.vim *** ../vim-8.2.4497/runtime/doc/map.txt 2022-01-15 18:25:04.657419390 +0000 --- runtime/doc/map.txt 2022-03-03 13:49:53.023594306 +0000 *************** *** 78,83 **** --- 80,87 ---- where the map command applies. Disallow mapping of {rhs}, to avoid nested and recursive mappings. Often used to redefine a command. + Note: When appears in the {rhs} this part is + always applied even if remapping is disallowed. :unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap* *************** *** 94,99 **** --- 98,105 ---- Remove the mapping of {lhs} for the modes where the map command applies. The mapping may remain defined for other modes where it applies. + It also works when {lhs} matches the {rhs} of a + mapping. This is for when an abbreviation applied. Note: Trailing spaces are included in the {lhs}. This unmap does NOT work: > :map @@ foo *** ../vim-8.2.4497/src/getchar.c 2022-02-20 19:05:06.359955597 +0000 --- src/getchar.c 2022-03-03 13:52:19.295476048 +0000 *************** *** 2424,2429 **** --- 2424,2436 ---- int keylen = *keylenp; int i; int local_State = get_real_state(); + int is_plug_map = FALSE; + + // If typehead starts with then remap, even for a "noremap" mapping. + if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL + && typebuf.tb_buf[typebuf.tb_off + 1] == KS_EXTRA + && typebuf.tb_buf[typebuf.tb_off + 2] == KE_PLUG) + is_plug_map = TRUE; /* * Check for a mappable key sequence. *************** *** 2441,2447 **** tb_c1 = typebuf.tb_buf[typebuf.tb_off]; if (no_mapping == 0 && is_maphash_valid() && (no_zero_mapping == 0 || tb_c1 != '0') ! && (typebuf.tb_maplen == 0 || (p_remap && (typebuf.tb_noremap[typebuf.tb_off] & (RM_NONE|RM_ABBR)) == 0)) --- 2448,2454 ---- tb_c1 = typebuf.tb_buf[typebuf.tb_off]; if (no_mapping == 0 && is_maphash_valid() && (no_zero_mapping == 0 || tb_c1 != '0') ! && (typebuf.tb_maplen == 0 || is_plug_map || (p_remap && (typebuf.tb_noremap[typebuf.tb_off] & (RM_NONE|RM_ABBR)) == 0)) *************** *** 2562,2568 **** for (n = mlen; --n >= 0; ) if (*s++ & (RM_NONE|RM_ABBR)) break; ! if (n >= 0) continue; if (keylen > typebuf.tb_len) --- 2569,2575 ---- for (n = mlen; --n >= 0; ) if (*s++ & (RM_NONE|RM_ABBR)) break; ! if (!is_plug_map && n >= 0) continue; if (keylen > typebuf.tb_len) *** ../vim-8.2.4497/src/testdir/test_mapping.vim 2022-02-16 18:27:32.583437344 +0000 --- src/testdir/test_mapping.vim 2022-03-03 13:54:22.731369088 +0000 *************** *** 1536,1539 **** --- 1536,1569 ---- set encoding=utf-8 endfunc + " Test for always being mapped, even when used with "noremap". + func Test_plug_remap() + let g:foo = 0 + nnoremap (Increase_x) let g:foo += 1 + nmap (Increase_x) + nnoremap (Increase_x) + call feedkeys("\", 'xt') + call assert_equal(1, g:foo) + call feedkeys("\", 'xt') + call assert_equal(2, g:foo) + nnoremap x + nmap x(Increase_x)x + nnoremap x(Increase_x)x + call setline(1, 'Some text') + normal! gg$ + call feedkeys("\", 'xt') + call assert_equal(3, g:foo) + call assert_equal('Some text', getline(1)) + call feedkeys("\", 'xt') + call assert_equal(4, g:foo) + call assert_equal('Some te', getline(1)) + nunmap (Increase_x) + nunmap + nunmap + nunmap + nunmap + unlet g:foo + %bw! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.4497/src/version.c 2022-03-03 11:45:37.347173149 +0000 --- src/version.c 2022-03-03 13:48:16.455665942 +0000 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 4498, /**/ -- hundred-and-one symptoms of being an internet addict: 150. You find yourself counting emoticons to get to sleep. /// 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 ///