mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 14:38:52 +08:00
move nerdtree#getTreeWinNum out of autoload
This commit is contained in:
parent
973c9906f8
commit
8270b6d717
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user