move TreeFileNode.makeRoot() to NERDTree.changeRoot(node)
This commit is contained in:
parent
71ee64fed7
commit
cedb40b4f5
@ -140,9 +140,7 @@ endfunction
|
||||
" FUNCTION: s:chRoot(node) {{{1
|
||||
" changes the current root to the selected one
|
||||
function! s:chRoot(node)
|
||||
call a:node.makeRoot()
|
||||
call b:NERDTree.render()
|
||||
call b:NERDTree.root.putCursorHere(0, 0)
|
||||
call b:NERDTree.changeRoot(a:node)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
|
||||
|
@ -275,9 +275,7 @@ function! s:Bookmark.toRoot()
|
||||
catch /^NERDTree.BookmarkedNodeNotFoundError/
|
||||
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path)
|
||||
endtry
|
||||
call targetNode.makeRoot()
|
||||
call b:NERDTree.render()
|
||||
call targetNode.putCursorHere(0, 0)
|
||||
call b:NERDTree.changeRoot(targetNode)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -8,6 +8,28 @@ function! s:NERDTree.AddPathFilter(callback)
|
||||
call add(s:NERDTree.PathFilters(), a:callback)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.changeRoot(node) {{{1
|
||||
function! s:NERDTree.changeRoot(node)
|
||||
if a:node.path.isDirectory
|
||||
let self.root = a:node
|
||||
else
|
||||
call a:node.cacheParent()
|
||||
let self.root = self.parent
|
||||
endif
|
||||
|
||||
call self.root.open()
|
||||
|
||||
"change dir to the dir of the new root if instructed to
|
||||
if g:NERDTreeChDirMode ==# 2
|
||||
exec "cd " . self.root.path.str({'format': 'Edit'})
|
||||
endif
|
||||
|
||||
call self.render()
|
||||
call self.root.putCursorHere(0, 0)
|
||||
|
||||
silent doautocmd User NERDTreeNewRoot
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.Close() {{{1
|
||||
"Closes the tab tree window for this tab
|
||||
function! s:NERDTree.Close()
|
||||
|
@ -268,9 +268,7 @@ function! s:Opener._openDirectory(node)
|
||||
else
|
||||
call self._gotoTargetWin()
|
||||
if empty(self._where)
|
||||
call a:node.makeRoot()
|
||||
call b:NERDTree.render()
|
||||
call a:node.putCursorHere(0, 0)
|
||||
call b:NERDTree.changeRoot(a:node)
|
||||
elseif self._where == 't'
|
||||
call g:NERDTreeCreator.CreateTabTree(a:node.path.str())
|
||||
else
|
||||
|
@ -218,26 +218,6 @@ function! s:TreeFileNode.isRoot()
|
||||
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:NERDTree.root = self
|
||||
else
|
||||
call self.cacheParent()
|
||||
let b:NERDTree.root = self.parent
|
||||
endif
|
||||
|
||||
call b:NERDTree.root.open()
|
||||
|
||||
"change dir to the dir of the new root if instructed to
|
||||
if g:NERDTreeChDirMode ==# 2
|
||||
exec "cd " . b:NERDTree.root.path.str({'format': 'Edit'})
|
||||
endif
|
||||
|
||||
silent doautocmd User NERDTreeNewRoot
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeFileNode.New(path) {{{1
|
||||
"Returns a new TreeNode object with the given path and parent
|
||||
"
|
||||
|
Loading…
Reference in New Issue
Block a user