From 1792b6a75b337d739dbc6cd16c3091e9f38923cd Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 22 Apr 2018 10:19:13 -0400 Subject: [PATCH 1/3] Clear output when the NERDTree menu is aborted Previously, exiting the NERDTree menu with "Ctrl-C" or "Esc" would leave the last line of the menu visible. We can avoid this by redrawing the screen when the menu is aborted in this manner. --- lib/nerdtree/menu_controller.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index ae0ee84..b28ca4d 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -33,6 +33,11 @@ function! s:MenuController.showMenu() endwhile finally call self._restoreOptions() + + " Redraw when "Ctrl-C" or "Esc" is received. + if !l:done || self.selection == -1 + redraw! + endif endtry if self.selection != -1 From 38d4d2288a83f08b8b2ba24f36259e3f140da9d6 Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 22 Apr 2018 10:21:16 -0400 Subject: [PATCH 2/3] Clean up a function comment --- lib/nerdtree/menu_controller.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index b28ca4d..f24e222 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -15,9 +15,9 @@ function! s:MenuController.New(menuItems) return newMenuController endfunction -"FUNCTION: MenuController.showMenu() {{{1 -"start the main loop of the menu and get the user to choose/execute a menu -"item +" FUNCTION: MenuController.showMenu() {{{1 +" Enter the main loop of the NERDTree menu, prompting the user to select +" a menu item. function! s:MenuController.showMenu() call self._saveOptions() From 164131762f1d37f7e7dc19e0ebe177c80c3f74ea Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Sun, 22 Apr 2018 10:23:16 -0400 Subject: [PATCH 3/3] Refine the internals of the "showMenu()" function --- lib/nerdtree/menu_controller.vim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/nerdtree/menu_controller.vim b/lib/nerdtree/menu_controller.vim index f24e222..68e4d30 100644 --- a/lib/nerdtree/menu_controller.vim +++ b/lib/nerdtree/menu_controller.vim @@ -23,13 +23,14 @@ function! s:MenuController.showMenu() try let self.selection = 0 + let l:done = 0 - let done = 0 - while !done + while !l:done redraw! call self._echoPrompt() - let key = nr2char(getchar()) - let done = self._handleKeypress(key) + + let l:key = nr2char(getchar()) + let l:done = self._handleKeypress(l:key) endwhile finally call self._restoreOptions() @@ -41,8 +42,8 @@ function! s:MenuController.showMenu() endtry if self.selection != -1 - let m = self._current() - call m.execute() + let l:m = self._current() + call l:m.execute() endif endfunction