From 456367ab07cd9d866b503a25e52aaa5a9fd8ad1f Mon Sep 17 00:00:00 2001 From: Jason Franklin Date: Thu, 2 Aug 2018 09:17:18 -0400 Subject: [PATCH] Put cursor on root when closing bookmark table If the cursor is not already positioned on a node when the bookmark table is closed, then the resulting position of the cursor is not determined. Here, we default to positioning the cursor on the root when the bookmark table is closed. --- lib/nerdtree/ui.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 68a72b6..0737310 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -475,15 +475,23 @@ function! s:UI.toggleIgnoreFilter() endfunction " FUNCTION: s:UI.toggleShowBookmarks() {{{1 -" toggles the display of bookmarks +" Toggle the visibility of the Bookmark table. function! s:UI.toggleShowBookmarks() let self._showBookmarks = !self._showBookmarks + if self.getShowBookmarks() call self.nerdtree.render() call g:NERDTree.CursorToBookmarkTable() else + + if empty(g:NERDTreeFileNode.GetSelected()) + call b:NERDTree.root.putCursorHere(0, 0) + normal! 0 + endif + call self.renderViewSavingPosition() endif + call self.centerView() endfunction