dont use b:NERDTreeRoot internally, but leave the var there for compat

Use b:NERDTree.root instead. I will eventually remove  b:NERDTreeRoot
altogether - but this will break some other plugins so leave it for now.
This commit is contained in:
Martin Grenfell
2015-11-16 11:28:24 +00:00
parent 0b966aa23a
commit d36b793656
10 changed files with 42 additions and 42 deletions

View File

@@ -147,7 +147,7 @@ endfunction
" searchFromAbsoluteRoot: specifies whether we should search from the current
" tree root, or the highest cached node
function! s:Bookmark.getNode(searchFromAbsoluteRoot)
let searchRoot = a:searchFromAbsoluteRoot ? g:NERDTreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot
let searchRoot = a:searchFromAbsoluteRoot ? g:NERDTreeDirNode.AbsoluteTreeRoot() : b:NERDTree.root
let targetNode = searchRoot.findNode(self.path)
if empty(targetNode)
throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name

View File

@@ -68,7 +68,7 @@ function! s:Creator.createTabTree(name)
call self._createTreeWin()
call self._createNERDTree(path, "tab")
call b:NERDTree.render()
call b:NERDTreeRoot.putCursorHere(0, 0)
call b:NERDTree.root.putCursorHere(0, 0)
call self._broadcastInitEvent()
endfunction
@@ -141,7 +141,7 @@ function! s:Creator.createMirror()
let i = 0
while i < len(treeBufNames)
let bufName = treeBufNames[i]
let treeRoot = getbufvar(bufName, "NERDTreeRoot")
let treeRoot = getbufvar(bufName, "NERDTree").root
let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName
let i = i + 1
endwhile

View File

@@ -73,7 +73,7 @@ endfunction
" Function: s:NERDTree.ExistsForBuffer() {{{1
" Returns 1 if a nerd tree root exists in the current buffer
function! s:NERDTree.ExistsForBuf()
return exists("b:NERDTreeRoot")
return exists("b:NERDTree")
endfunction
" Function: s:NERDTree.ExistsForTab() {{{1

View File

@@ -9,7 +9,7 @@ let g:NERDTreeDirNode = s:TreeDirNode
"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{1
"class method that returns the highest cached ancestor of the current root
function! s:TreeDirNode.AbsoluteTreeRoot()
let currentNode = b:NERDTreeRoot
let currentNode = b:NERDTree.root
while currentNode.parent != {}
let currentNode = currentNode.parent
endwhile

View File

@@ -59,7 +59,7 @@ endfunction
function! s:TreeFileNode.copy(dest)
call self.path.copy(a:dest)
let newPath = g:NERDTreePath.New(a:dest)
let parent = b:NERDTreeRoot.findNode(newPath.getParent())
let parent = b:NERDTree.root.findNode(newPath.getParent())
if !empty(parent)
call parent.refresh()
return parent.findNode(newPath)
@@ -182,7 +182,7 @@ endfunction
"get the root node for this tab
function! s:TreeFileNode.GetRootForTab()
if g:NERDTree.ExistsForTab()
return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot')
return getbufvar(t:NERDTreeBufName, 'NERDTree').root
end
return {}
endfunction
@@ -195,7 +195,7 @@ function! s:TreeFileNode.GetSelected()
if path ==# {}
return {}
endif
return b:NERDTreeRoot.findNode(path)
return b:NERDTree.root.findNode(path)
catch /^NERDTree/
return {}
endtry
@@ -209,30 +209,30 @@ function! s:TreeFileNode.isVisible()
endfunction
"FUNCTION: TreeFileNode.isRoot() {{{1
"returns 1 if this node is b:NERDTreeRoot
"returns 1 if this node is b:NERDTree.root
function! s:TreeFileNode.isRoot()
if !g:NERDTree.ExistsForBuf()
throw "NERDTree.NoTreeError: No tree exists for the current buffer"
endif
return self.equals(b:NERDTreeRoot)
return self.equals(b:NERDTree.root)
endfunction
"FUNCTION: TreeFileNode.makeRoot() {{{1
"Make this node the root of the tree
function! s:TreeFileNode.makeRoot()
if self.path.isDirectory
let b:NERDTreeRoot = self
let b:NERDTree.root = self
else
call self.cacheParent()
let b:NERDTreeRoot = self.parent
let b:NERDTree.root = self.parent
endif
call b:NERDTreeRoot.open()
call b:NERDTree.root.open()
"change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode ==# 2
exec "cd " . b:NERDTreeRoot.path.str({'format': 'Edit'})
exec "cd " . b:NERDTree.root.path.str({'format': 'Edit'})
endif
silent doautocmd User NERDTreeNewRoot
@@ -326,7 +326,7 @@ function! s:TreeFileNode.rename(newName)
call self.parent.removeChild(self)
let parentPath = self.path.getParent()
let newParent = b:NERDTreeRoot.findNode(parentPath)
let newParent = b:NERDTree.root.findNode(parentPath)
if newParent != {}
call newParent.createChild(self.path, 1)

View File

@@ -155,7 +155,7 @@ function! s:UI.getPath(ln)
"check to see if we have the root node
if a:ln == rootLine
return b:NERDTreeRoot.path
return self.nerdtree.root.path
endif
if !g:NERDTreeDirArrows
@@ -166,7 +166,7 @@ function! s:UI.getPath(ln)
endif
if line ==# s:UI.UpDirLine()
return b:NERDTreeRoot.path.getParent()
return self.nerdtree.root.path.getParent()
endif
let indent = self._indentLevelFor(line)
@@ -189,7 +189,7 @@ function! s:UI.getPath(ln)
"have we reached the top of the tree?
if lnum == rootLine
let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir
let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir
break
endif
if curLineStripped =~# '/$'
@@ -202,7 +202,7 @@ function! s:UI.getPath(ln)
endif
endif
endwhile
let curFile = b:NERDTreeRoot.path.drive . dir . curFile
let curFile = self.nerdtree.root.path.drive . dir . curFile
let toReturn = g:NERDTreePath.New(curFile)
return toReturn
endfunction
@@ -218,7 +218,7 @@ function! s:UI.getLineNum(file_node)
let totalLines = line("$")
"the path components we have matched so far
let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')]
let pathcomponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/ *$', '', '')]
"the index of the component we are searching for
let curPathComponent = 1
@@ -442,13 +442,13 @@ function! s:UI.render()
endif
"draw the header line
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
call setline(line(".")+1, header)
call cursor(line(".")+1, col("."))
"draw the tree
let old_o = @o
let @o = b:NERDTreeRoot.renderToString()
let @o = self.nerdtree.root.renderToString()
silent put o
let @o = old_o
@@ -504,7 +504,7 @@ endfunction
function! s:UI.toggleShowBookmarks()
let self._showBookmarks = !self._showBookmarks
if self.getShowBookmarks()
call b:NERDTree.render()
call self.nerdtree.render()
call g:NERDTree.CursorToBookmarkTable()
else
call self.renderViewSavingPosition()