move nerdtree#getTreeWinNum out of autoload

This commit is contained in:
Martin Grenfell 2015-05-02 14:31:57 +01:00
parent 973c9906f8
commit 8270b6d717
4 changed files with 16 additions and 16 deletions

View File

@ -106,7 +106,7 @@ function! nerdtree#closeTree()
endif endif
if winnr("$") != 1 if winnr("$") != 1
if winnr() == nerdtree#getTreeWinNum() if winnr() == g:NERDTree.GetWinNum()
call nerdtree#exec("wincmd p") call nerdtree#exec("wincmd p")
let bufnr = bufnr("") let bufnr = bufnr("")
call nerdtree#exec("wincmd p") call nerdtree#exec("wincmd p")
@ -114,7 +114,7 @@ function! nerdtree#closeTree()
let bufnr = bufnr("") let bufnr = bufnr("")
endif endif
call nerdtree#exec(nerdtree#getTreeWinNum() . " wincmd w") call nerdtree#exec(g:NERDTree.GetWinNum() . " wincmd w")
close close
call nerdtree#exec(bufwinnr(bufnr) . " wincmd w") call nerdtree#exec(bufwinnr(bufnr) . " wincmd w")
else else
@ -275,19 +275,9 @@ function! nerdtree#echoWarning(msg)
echohl normal echohl normal
endfunction 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() {{{2
function! nerdtree#isTreeOpen() function! nerdtree#isTreeOpen()
return nerdtree#getTreeWinNum() != -1 return g:NERDTree.GetWinNum() != -1
endfunction endfunction
"FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2 "FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2
@ -320,7 +310,7 @@ function! nerdtree#putCursorInTreeWin()
throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists" throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists"
endif endif
call nerdtree#exec(nerdtree#getTreeWinNum() . "wincmd w") call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w")
endfunction endfunction
"FUNCTION: nerdtree#renderBookmarks {{{2 "FUNCTION: nerdtree#renderBookmarks {{{2

View File

@ -253,7 +253,7 @@ endfunction
" FUNCTION: Bookmark.str() {{{1 " FUNCTION: Bookmark.str() {{{1
" Get the string that should be rendered in the view for this bookmark " Get the string that should be rendered in the view for this bookmark
function! s:Bookmark.str() 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 if &nu
let pathStrMaxLen = pathStrMaxLen - &numberwidth let pathStrMaxLen = pathStrMaxLen - &numberwidth
endif endif

View File

@ -23,6 +23,16 @@ function! s:NERDTree.ForCurrentBuf()
endif endif
endfunction 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) function! s:NERDTree.New(path)
let newObj = copy(self) let newObj = copy(self)
let newObj.ui = g:NERDTreeUI.New(newObj) let newObj.ui = g:NERDTreeUI.New(newObj)

View File

@ -15,7 +15,7 @@ function! s:UI.centerView()
if g:NERDTreeAutoCenter if g:NERDTreeAutoCenter
let current_line = winline() let current_line = winline()
let lines_to_top = current_line 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 if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold
normal! zz normal! zz
endif endif