Merge pull request #838 from lifecrisis/updir-fix
This commit is contained in:
commit
6188c5ea5f
@ -29,9 +29,9 @@ function! nerdtree#ui_glue#createDefaultBindings()
|
|||||||
|
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" })
|
||||||
|
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': 'all', 'callback': s . 'upDirCurrentRootClosed' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': 'all', 'callback': s . 'upDirCurrentRootOpen' })
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': 'Node', 'callback': s . 'chRoot' })
|
||||||
|
|
||||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" })
|
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" })
|
||||||
|
|
||||||
@ -619,40 +619,33 @@ function! s:toggleZoom()
|
|||||||
call b:NERDTree.ui.toggleZoom()
|
call b:NERDTree.ui.toggleZoom()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: nerdtree#ui_glue#upDir(keepState) {{{1
|
" FUNCTION: nerdtree#ui_glue#upDir(preserveState) {{{1
|
||||||
"moves the tree up a level
|
" Move the NERDTree up one level.
|
||||||
"
|
"
|
||||||
"Args:
|
" Args:
|
||||||
"keepState: 1 if the current root should be left open when the tree is
|
" preserveState: if 1, the current root is left open when the new tree is
|
||||||
"re-rendered
|
" rendered; if 0, the current root node is closed
|
||||||
function! nerdtree#ui_glue#upDir(keepState)
|
function! nerdtree#ui_glue#upDir(preserveState)
|
||||||
let cwd = b:NERDTree.root.path.str({'format': 'UI'})
|
|
||||||
if cwd ==# "/" || cwd =~# '^[^/]..$'
|
try
|
||||||
call nerdtree#echo("already at top dir")
|
call b:NERDTree.root.cacheParent()
|
||||||
else
|
catch /^NERDTree.CannotCacheParentError/
|
||||||
if !a:keepState
|
call nerdtree#echo('already at root directory')
|
||||||
call b:NERDTree.root.close()
|
return
|
||||||
|
endtry
|
||||||
|
|
||||||
|
let l:oldRoot = b:NERDTree.root
|
||||||
|
let l:newRoot = b:NERDTree.root.parent
|
||||||
|
|
||||||
|
call l:newRoot.open()
|
||||||
|
call l:newRoot.transplantChild(l:oldRoot)
|
||||||
|
|
||||||
|
if !a:preserveState
|
||||||
|
call l:oldRoot.close()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let oldRoot = b:NERDTree.root
|
call b:NERDTree.changeRoot(l:newRoot)
|
||||||
|
call l:oldRoot.putCursorHere(0, 0)
|
||||||
if empty(b:NERDTree.root.parent)
|
|
||||||
let path = b:NERDTree.root.path.getParent()
|
|
||||||
let newRoot = g:NERDTreeDirNode.New(path, b:NERDTree)
|
|
||||||
call newRoot.open()
|
|
||||||
call newRoot.transplantChild(b:NERDTree.root)
|
|
||||||
let b:NERDTree.root = newRoot
|
|
||||||
else
|
|
||||||
let b:NERDTree.root = b:NERDTree.root.parent
|
|
||||||
endif
|
|
||||||
|
|
||||||
if g:NERDTreeChDirMode ==# 2
|
|
||||||
call b:NERDTree.root.path.changeToDir()
|
|
||||||
endif
|
|
||||||
|
|
||||||
call b:NERDTree.render()
|
|
||||||
call oldRoot.putCursorHere(0, 0)
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:upDirCurrentRootOpen() {{{1
|
" FUNCTION: s:upDirCurrentRootOpen() {{{1
|
||||||
|
Loading…
Reference in New Issue
Block a user