mirror of
https://github.com/vim/vim.git
synced 2025-10-05 05:34:07 -04:00
patch 9.0.1687: mapset() not properly handling script ID
Problem: mapset() not properly handling script ID Solution: replace_termcodes() may accept a script ID closes: #12699 closes: #12697 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
committed by
Christian Brabandt
parent
cd4e4e169a
commit
7e0bae024d
@@ -494,8 +494,32 @@ func Test_map_restore()
|
||||
nunmap <C-B>
|
||||
endfunc
|
||||
|
||||
" Test restoring the script context of a mapping
|
||||
" Test restoring an <SID> mapping
|
||||
func Test_map_restore_sid()
|
||||
func RestoreMap()
|
||||
const d = maparg('<CR>', 'i', v:false, v:true)
|
||||
iunmap <buffer> <CR>
|
||||
call mapset('i', v:false, d)
|
||||
endfunc
|
||||
|
||||
let mapscript =<< trim [CODE]
|
||||
inoremap <silent><buffer> <SID>Return <C-R>=42<CR>
|
||||
inoremap <script><buffer> <CR> <CR><SID>Return
|
||||
[CODE]
|
||||
call writefile(mapscript, 'Xmapscript', 'D')
|
||||
|
||||
new
|
||||
source Xmapscript
|
||||
inoremap <buffer> <C-B> <Cmd>call RestoreMap()<CR>
|
||||
call feedkeys("i\<CR>\<C-B>\<CR>", 'xt')
|
||||
call assert_equal(['', '42', '42'], getline(1, '$'))
|
||||
|
||||
bwipe!
|
||||
delfunc RestoreMap
|
||||
endfunc
|
||||
|
||||
" Test restoring a mapping with a negative script ID
|
||||
func Test_map_restore_negative_sid()
|
||||
let after =<< trim [CODE]
|
||||
call assert_equal("\tLast set from --cmd argument",
|
||||
\ execute('verbose nmap ,n')->trim()->split("\n")[-1])
|
||||
|
Reference in New Issue
Block a user