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
|
" FUNCTION: s:chRoot(node) {{{1
|
||||||
" changes the current root to the selected one
|
" changes the current root to the selected one
|
||||||
function! s:chRoot(node)
|
function! s:chRoot(node)
|
||||||
call a:node.makeRoot()
|
call b:NERDTree.changeRoot(a:node)
|
||||||
call b:NERDTree.render()
|
|
||||||
call b:NERDTree.root.putCursorHere(0, 0)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
|
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
|
||||||
|
@ -275,9 +275,7 @@ function! s:Bookmark.toRoot()
|
|||||||
catch /^NERDTree.BookmarkedNodeNotFoundError/
|
catch /^NERDTree.BookmarkedNodeNotFoundError/
|
||||||
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path)
|
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path)
|
||||||
endtry
|
endtry
|
||||||
call targetNode.makeRoot()
|
call b:NERDTree.changeRoot(targetNode)
|
||||||
call b:NERDTree.render()
|
|
||||||
call targetNode.putCursorHere(0, 0)
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -8,6 +8,28 @@ function! s:NERDTree.AddPathFilter(callback)
|
|||||||
call add(s:NERDTree.PathFilters(), a:callback)
|
call add(s:NERDTree.PathFilters(), a:callback)
|
||||||
endfunction
|
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
|
"FUNCTION: s:NERDTree.Close() {{{1
|
||||||
"Closes the tab tree window for this tab
|
"Closes the tab tree window for this tab
|
||||||
function! s:NERDTree.Close()
|
function! s:NERDTree.Close()
|
||||||
|
@ -268,9 +268,7 @@ function! s:Opener._openDirectory(node)
|
|||||||
else
|
else
|
||||||
call self._gotoTargetWin()
|
call self._gotoTargetWin()
|
||||||
if empty(self._where)
|
if empty(self._where)
|
||||||
call a:node.makeRoot()
|
call b:NERDTree.changeRoot(a:node)
|
||||||
call b:NERDTree.render()
|
|
||||||
call a:node.putCursorHere(0, 0)
|
|
||||||
elseif self._where == 't'
|
elseif self._where == 't'
|
||||||
call g:NERDTreeCreator.CreateTabTree(a:node.path.str())
|
call g:NERDTreeCreator.CreateTabTree(a:node.path.str())
|
||||||
else
|
else
|
||||||
|
@ -218,26 +218,6 @@ function! s:TreeFileNode.isRoot()
|
|||||||
return self.equals(b:NERDTree.root)
|
return self.equals(b:NERDTree.root)
|
||||||
endfunction
|
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
|
"FUNCTION: TreeFileNode.New(path) {{{1
|
||||||
"Returns a new TreeNode object with the given path and parent
|
"Returns a new TreeNode object with the given path and parent
|
||||||
"
|
"
|
||||||
|
Loading…
Reference in New Issue
Block a user