mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
move a couple of functions into NERDTreeCreator
The "next buffer name" functions are only used in NERDTreeCreator so put them there.
This commit is contained in:
@@ -33,11 +33,6 @@ function! nerdtree#bufInWindows(bnum)
|
||||
return cnt
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#bufNamePrefix() {{{2
|
||||
function! nerdtree#bufNamePrefix()
|
||||
return 'NERD_tree_'
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
|
||||
"inits a secondary nerd tree in the current buffer if appropriate
|
||||
function! nerdtree#checkForBrowse(dir)
|
||||
@@ -232,25 +227,6 @@ function! nerdtree#invokeKeyMap(key)
|
||||
call g:NERDTreeKeyMap.Invoke(a:key)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#nextBufferName() {{{2
|
||||
" returns the buffer name for the next nerd tree
|
||||
function! nerdtree#nextBufferName()
|
||||
let name = nerdtree#bufNamePrefix() . nerdtree#nextBufferNumber()
|
||||
return name
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#nextBufferNumber() {{{2
|
||||
" the number to add to the nerd tree buffer name to make the buf name unique
|
||||
function! nerdtree#nextBufferNumber()
|
||||
if !exists("s:nextBufNum")
|
||||
let s:nextBufNum = 1
|
||||
else
|
||||
let s:nextBufNum += 1
|
||||
endif
|
||||
|
||||
return s:nextBufNum
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#postSourceActions() {{{2
|
||||
function! nerdtree#postSourceActions()
|
||||
call g:NERDTreeBookmark.CacheBookmarks(0)
|
||||
|
||||
@@ -161,10 +161,10 @@ command! -n=0 -bar NERDTreeCWD call NERDTreeCWD()
|
||||
"============================================================
|
||||
augroup NERDTree
|
||||
"Save the cursor position whenever we close the nerd tree
|
||||
exec "autocmd BufWinLeave ". nerdtree#bufNamePrefix() ."* call nerdtree#saveScreenState()"
|
||||
exec "autocmd BufWinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call nerdtree#saveScreenState()"
|
||||
|
||||
"disallow insert mode in the NERDTree
|
||||
exec "autocmd BufEnter ". nerdtree#bufNamePrefix() ."* stopinsert"
|
||||
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
|
||||
augroup END
|
||||
|
||||
if g:NERDTreeHijackNetrw
|
||||
|
||||
@@ -27,6 +27,11 @@ function! s:Creator._broadcastInitEvent()
|
||||
silent doautocmd User NERDTreeInit
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator.BufNamePrefix() {{{2
|
||||
function! s:Creator.BufNamePrefix()
|
||||
return 'NERD_tree_'
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1
|
||||
function! s:Creator.CreatePrimary(name)
|
||||
let creator = s:Creator.New()
|
||||
@@ -91,7 +96,7 @@ function! s:Creator.createSecondary(dir)
|
||||
|
||||
"we need a unique name for each secondary tree buffer to ensure they are
|
||||
"all independent
|
||||
exec "silent edit " . nerdtree#nextBufferName()
|
||||
exec "silent edit " . self._nextBufferName()
|
||||
|
||||
let b:NERDTreePreviousBuf = bufnr(previousBuf)
|
||||
|
||||
@@ -174,7 +179,7 @@ function! s:Creator._createTreeWin()
|
||||
let splitSize = g:NERDTreeWinSize
|
||||
|
||||
if !exists('t:NERDTreeBufName')
|
||||
let t:NERDTreeBufName = nerdtree#nextBufferName()
|
||||
let t:NERDTreeBufName = self._nextBufferName()
|
||||
silent! exec splitLocation . 'vertical ' . splitSize . ' new'
|
||||
silent! exec "edit " . t:NERDTreeBufName
|
||||
else
|
||||
@@ -192,6 +197,25 @@ function! s:Creator.New()
|
||||
return newCreator
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator._nextBufferName() {{{2
|
||||
" returns the buffer name for the next nerd tree
|
||||
function! s:Creator._nextBufferName()
|
||||
let name = s:Creator.BufNamePrefix() . self._nextBufferNumber()
|
||||
return name
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator._nextBufferNumber() {{{2
|
||||
" the number to add to the nerd tree buffer name to make the buf name unique
|
||||
function! s:Creator._nextBufferNumber()
|
||||
if !exists("s:Creator._NextBufNum")
|
||||
let s:Creator._NextBufNum = 1
|
||||
else
|
||||
let s:Creator._NextBufNum += 1
|
||||
endif
|
||||
|
||||
return s:Creator._NextBufNum
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator._pathForString(str) {{{1
|
||||
"find a bookmark or adirectory for the given string
|
||||
function! s:Creator._pathForString(str)
|
||||
|
||||
Reference in New Issue
Block a user