From 8270b6d71782930306b5788b218af82c59b01224 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sat, 2 May 2015 14:31:57 +0100 Subject: [PATCH] move nerdtree#getTreeWinNum out of autoload --- autoload/nerdtree.vim | 18 ++++-------------- lib/nerdtree/bookmark.vim | 2 +- lib/nerdtree/nerdtree.vim | 10 ++++++++++ lib/nerdtree/ui.vim | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index d68faaa..be1afbe 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -106,7 +106,7 @@ function! nerdtree#closeTree() endif if winnr("$") != 1 - if winnr() == nerdtree#getTreeWinNum() + if winnr() == g:NERDTree.GetWinNum() call nerdtree#exec("wincmd p") let bufnr = bufnr("") call nerdtree#exec("wincmd p") @@ -114,7 +114,7 @@ function! nerdtree#closeTree() let bufnr = bufnr("") endif - call nerdtree#exec(nerdtree#getTreeWinNum() . " wincmd w") + call nerdtree#exec(g:NERDTree.GetWinNum() . " wincmd w") close call nerdtree#exec(bufwinnr(bufnr) . " wincmd w") else @@ -275,19 +275,9 @@ function! nerdtree#echoWarning(msg) echohl normal endfunction -"FUNCTION: nerdtree#getTreeWinNum() {{{2 -"gets the nerd tree window number for this tab -function! nerdtree#getTreeWinNum() - if exists("t:NERDTreeBufName") - return bufwinnr(t:NERDTreeBufName) - else - return -1 - endif -endfunction - "FUNCTION: nerdtree#isTreeOpen() {{{2 function! nerdtree#isTreeOpen() - return nerdtree#getTreeWinNum() != -1 + return g:NERDTree.GetWinNum() != -1 endfunction "FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2 @@ -320,7 +310,7 @@ function! nerdtree#putCursorInTreeWin() throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists" endif - call nerdtree#exec(nerdtree#getTreeWinNum() . "wincmd w") + call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w") endfunction "FUNCTION: nerdtree#renderBookmarks {{{2 diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 6de9be4..8a94b25 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -253,7 +253,7 @@ endfunction " FUNCTION: Bookmark.str() {{{1 " Get the string that should be rendered in the view for this bookmark function! s:Bookmark.str() - let pathStrMaxLen = winwidth(nerdtree#getTreeWinNum()) - 4 - len(self.name) + let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - len(self.name) if &nu let pathStrMaxLen = pathStrMaxLen - &numberwidth endif diff --git a/lib/nerdtree/nerdtree.vim b/lib/nerdtree/nerdtree.vim index a41490b..91ccc53 100644 --- a/lib/nerdtree/nerdtree.vim +++ b/lib/nerdtree/nerdtree.vim @@ -23,6 +23,16 @@ function! s:NERDTree.ForCurrentBuf() endif endfunction +"FUNCTION: s:NERDTree.GetWinNum() {{{1 +"gets the nerd tree window number for this tab +function! s:NERDTree.GetWinNum() + if exists("t:NERDTreeBufName") + return bufwinnr(t:NERDTreeBufName) + else + return -1 + endif +endfunction + function! s:NERDTree.New(path) let newObj = copy(self) let newObj.ui = g:NERDTreeUI.New(newObj) diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 8382b4f..209f826 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -15,7 +15,7 @@ function! s:UI.centerView() if g:NERDTreeAutoCenter let current_line = winline() let lines_to_top = current_line - let lines_to_bottom = winheight(nerdtree#getTreeWinNum()) - current_line + let lines_to_bottom = winheight(g:NERDTree.GetWinNum()) - current_line if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold normal! zz endif