From 044f327c8d4bff901415c450b18975e6043f18ad Mon Sep 17 00:00:00 2001 From: "omri.sarig13@gmail.com" Date: Fri, 26 Jul 2019 17:16:41 +0300 Subject: [PATCH] Add test before remapping plugin's maps The plugin maps the some keys to run the commands of the plugin automatically by themselves. Until now, those commands were always mapped, regardless of the state of the plugin and the mapping themselves. This caused two problems: * When the plugin was not enabled the mapping still existed. * When the mapping was empty, an error massage was generated. To fix both of those problems, I added two tests before running the mappings: first, it checks that the plugins is indeed enabled, and then it checks that the mapping is not empty. Only in case both of those tests passes, the commands are mapped. --- plugin/winresizer.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugin/winresizer.vim b/plugin/winresizer.vim index 7ff6bac..a1ad279 100644 --- a/plugin/winresizer.vim +++ b/plugin/winresizer.vim @@ -116,14 +116,18 @@ let s:codeList = { \ 'mode' : g:winresizer_keycode_mode, \} -exe 'nnoremap ' . g:winresizer_start_key .' :WinResizerStartResize' +if g:winresizer_enable != 0 && !empty(g:winresizer_start_key) + exe 'nnoremap ' . g:winresizer_start_key .' :WinResizerStartResize' +endif com! WinResizerStartResize call s:startResize(s:tuiResizeCommands()) com! WinResizerStartMove call s:startResize(s:moveCommands()) com! WinResizerStartFocus call s:startResize(s:focusCommands()) -if has("gui_running") && g:winresizer_gui_enable != 0 - exe 'nnoremap ' . g:winresizer_gui_start_key .' :WinResizerStartResizeGUI' +if has("gui_running") && g:winresizer_gui_enable != 0 && g:winresizer_enable != 0 + if !empty(g:winresizer_gui_start_key) + exe 'nnoremap ' . g:winresizer_gui_start_key .' :WinResizerStartResizeGUI' + endif com! WinResizerStartResizeGUI call s:startResize(s:guiResizeCommands()) endif