To: vim_dev@googlegroups.com Subject: Patch 8.2.4148 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4148 Problem: Deleting any mapping may cause to not set the script context. Solution: Only reset last_used_map if it is the deleted mapping. (closes #9568) Files: src/map.c, src/getchar.c, src/proto/getchar.pro, src/testdir/test_mapping.vim *** ../vim-8.2.4147/src/map.c 2022-01-18 20:51:29.702559521 +0000 --- src/map.c 2022-01-19 22:30:39.167049010 +0000 *************** *** 86,92 **** *mpp = mp->m_next; vim_free(mp); #ifdef FEAT_EVAL ! reset_last_used_map(); #endif } --- 86,92 ---- *mpp = mp->m_next; vim_free(mp); #ifdef FEAT_EVAL ! reset_last_used_map(mp); #endif } *** ../vim-8.2.4147/src/getchar.c 2022-01-16 13:30:29.877688041 +0000 --- src/getchar.c 2022-01-19 22:47:02.183384369 +0000 *************** *** 3836,3843 **** #if defined(FEAT_EVAL) || defined(PROTO) void ! reset_last_used_map(void) { ! last_used_map = NULL; } #endif --- 3836,3844 ---- #if defined(FEAT_EVAL) || defined(PROTO) void ! reset_last_used_map(mapblock_T *mp) { ! if (last_used_map == mp) ! last_used_map = NULL; } #endif *** ../vim-8.2.4147/src/proto/getchar.pro 2022-01-15 18:25:04.657419390 +0000 --- src/proto/getchar.pro 2022-01-19 22:32:34.308900441 +0000 *************** *** 53,57 **** int fix_input_buffer(char_u *buf, int len); int input_available(void); int do_cmdkey_command(int key, int flags); ! void reset_last_used_map(void); /* vim: set ft=c : */ --- 53,57 ---- int fix_input_buffer(char_u *buf, int len); int input_available(void); int do_cmdkey_command(int key, int flags); ! void reset_last_used_map(mapblock_T *mp); /* vim: set ft=c : */ *** ../vim-8.2.4147/src/testdir/test_mapping.vim 2022-01-18 20:30:31.408458462 +0000 --- src/testdir/test_mapping.vim 2022-01-19 22:46:38.071877216 +0000 *************** *** 1439,1444 **** --- 1439,1460 ---- unlet g:func_called endfunc + func Test_map_script_cmd_survives_unmap() + let lines =<< trim END + vim9script + var n = 123 + nnoremap + autocmd CmdlineEnter * silent! nunmap + nnoremap :eval setbufvar(bufnr(), "result", n) + feedkeys("\\", 'xct') + assert_equal(123, b:result) + END + call CheckScriptSuccess(lines) + + nunmap + unlet b:result + endfunc + " Test for using