From 2dfcd5a22b8f26091aa7398fdb8b0ea70ed7b28d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Nov 2023 18:16:49 +0800 Subject: vim-patch:8.2.4820: not simple programmatic way to find a specific mapping Problem: Not simple programmatic way to find a specific mapping. Solution: Add getmappings(). (Ernie Rael, closes vim/vim#10273) https://github.com/vim/vim/commit/659c240cf769925ff432b88df8719e7ace4629b0 Co-authored-by: Ernie Rael --- test/old/testdir/test_maparg.vim | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_maparg.vim b/test/old/testdir/test_maparg.vim index 17f3dcab8f..b0671d3b31 100644 --- a/test/old/testdir/test_maparg.vim +++ b/test/old/testdir/test_maparg.vim @@ -372,4 +372,76 @@ func Test_map_restore_negative_sid() call delete('Xresult') endfunc +func Test_getmappings() + new + func s:ClearMaps() + mapclear | nmapclear | vmapclear | xmapclear | smapclear | omapclear + mapclear! | imapclear | lmapclear | cmapclear | tmapclear + mapclear | nmapclear | vmapclear + xmapclear | smapclear | omapclear + mapclear! | imapclear | lmapclear + cmapclear | tmapclear + endfunc + + func s:AddMaps(new, accum) + if len(a:new) > 0 && a:new[0] != "No mapping found" + eval a:accum->extend(a:new) + endif + endfunc + + call s:ClearMaps() + call assert_equal(0, len(getmappings())) + + " Set up some mappings. + map dup bar + map dup bufbar + map foo isfoo + vnoremap