Patch 9.0.1442
Problem: mapset() does not restore non-script context.
Solution: Also accept negative sid. (closes #12132)
Files: src/map.c, src/testdir/test_map_functions.vim
*** ../vim-9.0.1441/src/map.c 2023-02-27 12:47:44.103282399 +0000
--- src/map.c 2023-04-07 22:07:25.788355007 +0100
***************
*** 227,233 ****
int is_abbr,
#ifdef FEAT_EVAL
int expr,
! scid_T sid, // -1 to use current_sctx
int scriptversion,
linenr_T lnum,
#endif
--- 227,233 ----
int is_abbr,
#ifdef FEAT_EVAL
int expr,
! scid_T sid, // 0 to use current_sctx
int scriptversion,
linenr_T lnum,
#endif
***************
*** 266,272 ****
mp->m_simplified = simplified;
#ifdef FEAT_EVAL
mp->m_expr = expr;
! if (sid > 0)
{
mp->m_script_ctx.sc_sid = sid;
mp->m_script_ctx.sc_lnum = lnum;
--- 266,272 ----
mp->m_simplified = simplified;
#ifdef FEAT_EVAL
mp->m_expr = expr;
! if (sid != 0)
{
mp->m_script_ctx.sc_sid = sid;
mp->m_script_ctx.sc_lnum = lnum;
***************
*** 924,930 ****
if (map_add(map_table, abbr_table, keys, rhs, orig_rhs,
noremap, nowait, silent, mode, abbrev,
#ifdef FEAT_EVAL
! expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0,
#endif
keyround1_simplified) == FAIL)
{
--- 924,930 ----
if (map_add(map_table, abbr_table, keys, rhs, orig_rhs,
noremap, nowait, silent, mode, abbrev,
#ifdef FEAT_EVAL
! expr, /* sid */ 0, /* scriptversion */ 0, /* lnum */ 0,
#endif
keyround1_simplified) == FAIL)
{
*** ../vim-9.0.1441/src/testdir/test_map_functions.vim 2023-01-28 19:18:56.729720605 +0000
--- src/testdir/test_map_functions.vim 2023-04-07 22:05:11.276431467 +0100
***************
*** 1,6 ****
--- 1,8 ----
" Tests for maparg(), mapcheck(), mapset(), maplist()
" Also test utf8 map with a 0x80 byte.
+ source shared.vim
+
func s:SID()
return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$'))
endfunc
***************
*** 490,496 ****
--- 492,519 ----
call Check_ctrlb_map(dsimp, 0)
nunmap <C-B>
+ endfunc
+ " Test restoring the script context of a mapping
+ func Test_map_restore_sid()
+ let after =<< trim [CODE]
+ call assert_equal("\tLast set from --cmd argument",
+ \ execute('verbose nmap ,n')->trim()->split("\n")[-1])
+ let d = maparg(',n', 'n', 0, 1)
+ nunmap ,n
+ call assert_equal('No mapping found',
+ \ execute('verbose nmap ,n')->trim()->split("\n")[-1])
+ call mapset('n', 0, d)
+ call assert_equal("\tLast set from --cmd argument",
+ \ execute('verbose nmap ,n')->trim()->split("\n")[-1])
+ call writefile(v:errors, 'Xresult')
+ qall!
+ [CODE]
+
+ if RunVim([], after, '--clean --cmd "nmap ,n <Nop>"')
+ call assert_equal([], readfile('Xresult'))
+ endif
+ call delete('Xresult')
endfunc
def Test_maplist()
*** ../vim-9.0.1441/src/version.c 2023-04-05 18:24:46.144030386 +0100
--- src/version.c 2023-04-07 22:06:38.980380403 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1442,
/**/
--
[SIR LAUNCELOT runs back up the stairs, grabs a rope
of the wall and swings out over the heads of the CROWD in a
swashbuckling manner towards a large window. He stops just short
of the window and is left swing pathetically back and forth.]
LAUNCELOT: Excuse me ... could somebody give me a push ...
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Br...@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 ///