aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-12 06:08:07 +0800
committerGitHub <noreply@github.com>2023-08-12 06:08:07 +0800
commit713311be62db5c5453bcd0a7f1dbed8d1d1add15 (patch)
treead7e949fcda8d40a01872c398d21f27e15600fe1 /test
parent6e0c36ba0e6691401726fd4215f89729138ba82f (diff)
downloadrneovim-713311be62db5c5453bcd0a7f1dbed8d1d1add15.tar.gz
rneovim-713311be62db5c5453bcd0a7f1dbed8d1d1add15.tar.bz2
rneovim-713311be62db5c5453bcd0a7f1dbed8d1d1add15.zip
vim-patch:9.0.1687: mapset() not properly handling script ID (#24666)
Problem: mapset() not properly handling script ID Solution: replace_termcodes() may accept a script ID closes: vim/vim#12699 closes: vim/vim#12697 https://github.com/vim/vim/commit/7e0bae024d4c1673cff31763227ad52b936fa56f
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_maparg.vim26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/old/testdir/test_maparg.vim b/test/old/testdir/test_maparg.vim
index 12670671dd..46b65d45cf 100644
--- a/test/old/testdir/test_maparg.vim
+++ b/test/old/testdir/test_maparg.vim
@@ -322,8 +322,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])