mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.4140: maparg() does not indicate the type of script
Problem: maparg() does not indicate the type of script where it was defined.
Solution: Add "scriptversion".
a9528b39a6
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
610f50ddaf
commit
a4b80c71ea
1
runtime/doc/builtin.txt
generated
1
runtime/doc/builtin.txt
generated
@ -4180,6 +4180,7 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
|
|||||||
(|mapmode-ic|)
|
(|mapmode-ic|)
|
||||||
"sid" The script local ID, used for <sid> mappings
|
"sid" The script local ID, used for <sid> mappings
|
||||||
(|<SID>|). Negative for special contexts.
|
(|<SID>|). Negative for special contexts.
|
||||||
|
"scriptversion" The version of the script, always 1.
|
||||||
"lnum" The line number in "sid", zero if unknown.
|
"lnum" The line number in "sid", zero if unknown.
|
||||||
"nowait" Do not wait for other, longer mappings.
|
"nowait" Do not wait for other, longer mappings.
|
||||||
(|:map-<nowait>|).
|
(|:map-<nowait>|).
|
||||||
|
1
runtime/lua/vim/_meta/vimfn.lua
generated
1
runtime/lua/vim/_meta/vimfn.lua
generated
@ -5041,6 +5041,7 @@ function vim.fn.map(expr1, expr2) end
|
|||||||
--- (|mapmode-ic|)
|
--- (|mapmode-ic|)
|
||||||
--- "sid" The script local ID, used for <sid> mappings
|
--- "sid" The script local ID, used for <sid> mappings
|
||||||
--- (|<SID>|). Negative for special contexts.
|
--- (|<SID>|). Negative for special contexts.
|
||||||
|
--- "scriptversion" The version of the script, always 1.
|
||||||
--- "lnum" The line number in "sid", zero if unknown.
|
--- "lnum" The line number in "sid", zero if unknown.
|
||||||
--- "nowait" Do not wait for other, longer mappings.
|
--- "nowait" Do not wait for other, longer mappings.
|
||||||
--- (|:map-<nowait>|).
|
--- (|:map-<nowait>|).
|
||||||
|
@ -6189,6 +6189,7 @@ M.funcs = {
|
|||||||
(|mapmode-ic|)
|
(|mapmode-ic|)
|
||||||
"sid" The script local ID, used for <sid> mappings
|
"sid" The script local ID, used for <sid> mappings
|
||||||
(|<SID>|). Negative for special contexts.
|
(|<SID>|). Negative for special contexts.
|
||||||
|
"scriptversion" The version of the script, always 1.
|
||||||
"lnum" The line number in "sid", zero if unknown.
|
"lnum" The line number in "sid", zero if unknown.
|
||||||
"nowait" Do not wait for other, longer mappings.
|
"nowait" Do not wait for other, longer mappings.
|
||||||
(|:map-<nowait>|).
|
(|:map-<nowait>|).
|
||||||
|
@ -2113,6 +2113,7 @@ static Dictionary mapblock_fill_dict(const mapblock_T *const mp, const char *lhs
|
|||||||
PUT(dict, "expr", INTEGER_OBJ(mp->m_expr ? 1 : 0));
|
PUT(dict, "expr", INTEGER_OBJ(mp->m_expr ? 1 : 0));
|
||||||
PUT(dict, "silent", INTEGER_OBJ(mp->m_silent ? 1 : 0));
|
PUT(dict, "silent", INTEGER_OBJ(mp->m_silent ? 1 : 0));
|
||||||
PUT(dict, "sid", INTEGER_OBJ(mp->m_script_ctx.sc_sid));
|
PUT(dict, "sid", INTEGER_OBJ(mp->m_script_ctx.sc_sid));
|
||||||
|
PUT(dict, "scriptversion", INTEGER_OBJ(1));
|
||||||
PUT(dict, "lnum", INTEGER_OBJ(mp->m_script_ctx.sc_lnum));
|
PUT(dict, "lnum", INTEGER_OBJ(mp->m_script_ctx.sc_lnum));
|
||||||
PUT(dict, "buffer", INTEGER_OBJ(buffer_value));
|
PUT(dict, "buffer", INTEGER_OBJ(buffer_value));
|
||||||
PUT(dict, "nowait", INTEGER_OBJ(mp->m_nowait ? 1 : 0));
|
PUT(dict, "nowait", INTEGER_OBJ(mp->m_nowait ? 1 : 0));
|
||||||
|
@ -32,6 +32,7 @@ describe('nvim_get_keymap', function()
|
|||||||
rhs='bar',
|
rhs='bar',
|
||||||
expr=0,
|
expr=0,
|
||||||
sid=0,
|
sid=0,
|
||||||
|
scriptversion=1,
|
||||||
buffer=0,
|
buffer=0,
|
||||||
nowait=0,
|
nowait=0,
|
||||||
mode='n',
|
mode='n',
|
||||||
@ -258,6 +259,7 @@ describe('nvim_get_keymap', function()
|
|||||||
silent=0,
|
silent=0,
|
||||||
expr=0,
|
expr=0,
|
||||||
sid=0,
|
sid=0,
|
||||||
|
scriptversion=1,
|
||||||
buffer=0,
|
buffer=0,
|
||||||
nowait=0,
|
nowait=0,
|
||||||
noremap=1,
|
noremap=1,
|
||||||
@ -327,6 +329,7 @@ describe('nvim_get_keymap', function()
|
|||||||
silent=0,
|
silent=0,
|
||||||
expr=0,
|
expr=0,
|
||||||
sid=0,
|
sid=0,
|
||||||
|
scriptversion=1,
|
||||||
buffer=0,
|
buffer=0,
|
||||||
nowait=0,
|
nowait=0,
|
||||||
noremap=1,
|
noremap=1,
|
||||||
@ -365,6 +368,7 @@ describe('nvim_get_keymap', function()
|
|||||||
silent=0,
|
silent=0,
|
||||||
expr=0,
|
expr=0,
|
||||||
sid=sid_lua,
|
sid=sid_lua,
|
||||||
|
scriptversion=1,
|
||||||
buffer=0,
|
buffer=0,
|
||||||
nowait=0,
|
nowait=0,
|
||||||
mode='n',
|
mode='n',
|
||||||
@ -373,7 +377,7 @@ describe('nvim_get_keymap', function()
|
|||||||
}, mapargs[1])
|
}, mapargs[1])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it ('can handle map descriptions', function()
|
it('can handle map descriptions', function()
|
||||||
meths.set_keymap('n', 'lhs', 'rhs', {desc="map description"})
|
meths.set_keymap('n', 'lhs', 'rhs', {desc="map description"})
|
||||||
eq({
|
eq({
|
||||||
lhs='lhs',
|
lhs='lhs',
|
||||||
@ -383,6 +387,7 @@ describe('nvim_get_keymap', function()
|
|||||||
silent=0,
|
silent=0,
|
||||||
expr=0,
|
expr=0,
|
||||||
sid=sid_api_client,
|
sid=sid_api_client,
|
||||||
|
scriptversion=1,
|
||||||
buffer=0,
|
buffer=0,
|
||||||
nowait=0,
|
nowait=0,
|
||||||
mode='n',
|
mode='n',
|
||||||
@ -429,6 +434,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
to_return.nowait = not opts.nowait and 0 or 1
|
to_return.nowait = not opts.nowait and 0 or 1
|
||||||
to_return.expr = not opts.expr and 0 or 1
|
to_return.expr = not opts.expr and 0 or 1
|
||||||
to_return.sid = not opts.sid and sid_api_client or opts.sid
|
to_return.sid = not opts.sid and sid_api_client or opts.sid
|
||||||
|
to_return.scriptversion = 1
|
||||||
to_return.buffer = not opts.buffer and 0 or opts.buffer
|
to_return.buffer = not opts.buffer and 0 or opts.buffer
|
||||||
to_return.lnum = not opts.lnum and 0 or opts.lnum
|
to_return.lnum = not opts.lnum and 0 or opts.lnum
|
||||||
to_return.desc = opts.desc
|
to_return.desc = opts.desc
|
||||||
|
@ -26,6 +26,7 @@ describe('maparg()', function()
|
|||||||
rhs='bar',
|
rhs='bar',
|
||||||
expr=0,
|
expr=0,
|
||||||
sid=0,
|
sid=0,
|
||||||
|
scriptversion=1,
|
||||||
buffer=0,
|
buffer=0,
|
||||||
nowait=0,
|
nowait=0,
|
||||||
mode='n',
|
mode='n',
|
||||||
@ -157,8 +158,9 @@ describe('maparg()', function()
|
|||||||
mode = 'n',
|
mode = 'n',
|
||||||
noremap = 1,
|
noremap = 1,
|
||||||
nowait = 0,
|
nowait = 0,
|
||||||
script=0,
|
script = 0,
|
||||||
sid = 0,
|
sid = 0,
|
||||||
|
scriptversion = 1,
|
||||||
silent = 0,
|
silent = 0,
|
||||||
lnum = 0,
|
lnum = 0,
|
||||||
}
|
}
|
||||||
|
@ -19,26 +19,30 @@ func Test_maparg()
|
|||||||
call assert_equal("is<F4>foo", maparg('foo<C-V>'))
|
call assert_equal("is<F4>foo", maparg('foo<C-V>'))
|
||||||
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>',
|
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>',
|
||||||
\ 'lhsraw': "foo\x80\xfc\x04V", 'lhsrawalt': "foo\x16",
|
\ 'lhsraw': "foo\x80\xfc\x04V", 'lhsrawalt': "foo\x16",
|
||||||
\ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1,
|
\ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1,
|
||||||
|
\ 'lnum': lnum + 1,
|
||||||
\ 'rhs': 'is<F4>foo', 'buffer': 0},
|
\ 'rhs': 'is<F4>foo', 'buffer': 0},
|
||||||
\ maparg('foo<C-V>', '', 0, 1))
|
\ maparg('foo<C-V>', '', 0, 1))
|
||||||
call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar',
|
call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar',
|
||||||
\ 'lhsraw': 'bar', 'mode': 'v',
|
\ 'lhsraw': 'bar', 'mode': 'v',
|
||||||
\ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
|
\ 'nowait': 0, 'expr': 1, 'sid': sid, 'scriptversion': 1,
|
||||||
|
\ 'lnum': lnum + 2,
|
||||||
\ 'rhs': 'isbar', 'buffer': 1},
|
\ 'rhs': 'isbar', 'buffer': 1},
|
||||||
\ 'bar'->maparg('', 0, 1))
|
\ 'bar'->maparg('', 0, 1))
|
||||||
let lnum = expand('<sflnum>')
|
let lnum = expand('<sflnum>')
|
||||||
map <buffer> <nowait> foo bar
|
map <buffer> <nowait> foo bar
|
||||||
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo',
|
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo',
|
||||||
\ 'lhsraw': 'foo', 'mode': ' ',
|
\ 'lhsraw': 'foo', 'mode': ' ',
|
||||||
\ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar',
|
\ 'nowait': 1, 'expr': 0, 'sid': sid, 'scriptversion': 1,
|
||||||
|
\ 'lnum': lnum + 1, 'rhs': 'bar',
|
||||||
\ 'buffer': 1},
|
\ 'buffer': 1},
|
||||||
\ maparg('foo', '', 0, 1))
|
\ maparg('foo', '', 0, 1))
|
||||||
let lnum = expand('<sflnum>')
|
let lnum = expand('<sflnum>')
|
||||||
tmap baz foo
|
tmap baz foo
|
||||||
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz',
|
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz',
|
||||||
\ 'lhsraw': 'baz', 'mode': 't',
|
\ 'lhsraw': 'baz', 'mode': 't',
|
||||||
\ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo',
|
\ 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1,
|
||||||
|
\ 'lnum': lnum + 1, 'rhs': 'foo',
|
||||||
\ 'buffer': 0},
|
\ 'buffer': 0},
|
||||||
\ maparg('baz', 't', 0, 1))
|
\ maparg('baz', 't', 0, 1))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user