From a9d157fa0f85c6e6c84e7aeb4606d361bf0c24ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Wed, 13 Jan 2021 01:43:00 +0100 Subject: [PATCH] Restore list item toggle on Unix systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A changed aimed to allow user configuration files to be able to override all default mappings for the VimwikiToggleListItem plug did so by removing the optional forth argument to vimwiki#u#map_key(). This argument if set to 1 allows the same plug to be mapped to multiple keys in the same mode. If not present only the first mapping takes effect and all later attempts to map the plug in the same mode result in a no-op. Thus allowing any user configuration to set it first and then 'skipping' the defaults. The change however did not account for that the default on Unix systems was to map both _and_ to VimwikiToggleListItem so the change breaks this behavior, described in issue #1061. Fix this by restoring the forth argument to vimwiki#u#map_key() to allow multiple mappings to the same plug/mode but wrap it in a block to first check if the user have overridden it or not. This goes back to how his was handled before vimwiki#u#map_key() was added in [1]. 1. 4106cb7bc739a45f ("New option g:vimwiki_key_mappings to enable/disable key mappings.") Fixes: 48baa1f4cd1bb496 ("Allow VimwikiToggleListItem mapping to be replaced (#1047)") Signed-off-by: Niklas Söderlund --- ftplugin/vimwiki.vim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index d8af835..838e197 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -509,11 +509,13 @@ nnoremap VimwikiListO " Declare Map: default lists key mappings (again) if str2nr(vimwiki#vars#get_global('key_mappings').lists) call vimwiki#u#map_key('n', 'gnt', 'VimwikiNextTask') - call vimwiki#u#map_key('n', '', 'VimwikiToggleListItem') - call vimwiki#u#map_key('v', '', 'VimwikiToggleListItem') - if has('unix') - call vimwiki#u#map_key('n', '', 'VimwikiToggleListItem') - call vimwiki#u#map_key('v', '', 'VimwikiToggleListItem') + if !hasmapto('VimwikiToggleListItem') + call vimwiki#u#map_key('n', '', 'VimwikiToggleListItem') + call vimwiki#u#map_key('v', '', 'VimwikiToggleListItem', 1) + if has('unix') + call vimwiki#u#map_key('n', '', 'VimwikiToggleListItem', 1) + call vimwiki#u#map_key('v', '', 'VimwikiToggleListItem', 1) + endif endif call vimwiki#u#map_key('n', 'glx', 'VimwikiToggleRejectedListItem') call vimwiki#u#map_key('v', 'glx', 'VimwikiToggleRejectedListItem', 1)