use buffer level variables instead of tab lvl

This commit is contained in:
Martin Grenfell 2008-12-13 19:29:03 +13:00
parent 9aba1c17f6
commit b0297c5c91

View File

@ -129,7 +129,7 @@ call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U")
"SECTION: Script level variable declaration{{{2 "SECTION: Script level variable declaration{{{2
let s:escape_chars = " \\`\|\"#%&,?()\*^<>" let s:escape_chars = " \\`\|\"#%&,?()\*^<>"
let s:NERDTreeWinName = '_NERD_tree_' let s:NERDTreeBufName = '_NERD_tree_'
let s:tree_wid = 2 let s:tree_wid = 2
let s:tree_markup_reg = '^[ `|]*[\-+~]' let s:tree_markup_reg = '^[ `|]*[\-+~]'
@ -150,7 +150,7 @@ command! -n=1 -complete=customlist,s:completeBookmarks NERDTreeFromBookmark call
" SECTION: Auto commands {{{1 " SECTION: Auto commands {{{1
"============================================================ "============================================================
"Save the cursor position whenever we close the nerd tree "Save the cursor position whenever we close the nerd tree
exec "autocmd BufWinLeave *". s:NERDTreeWinName ." call <SID>saveScreenState()" exec "autocmd BufWinLeave *". s:NERDTreeBufName ." call <SID>saveScreenState()"
"cache bookmarks when vim loads "cache bookmarks when vim loads
autocmd VimEnter * call s:Bookmark.CacheBookmarks(0) autocmd VimEnter * call s:Bookmark.CacheBookmarks(0)
@ -285,7 +285,7 @@ endfunction
" searchFromAbsoluteRoot: specifies whether we should search from the current " searchFromAbsoluteRoot: specifies whether we should search from the current
" tree root, or the highest cached node " tree root, or the highest cached node
function! s:Bookmark.getNode(searchFromAbsoluteRoot) function! s:Bookmark.getNode(searchFromAbsoluteRoot)
let searchRoot = a:searchFromAbsoluteRoot ? s:TreeDirNode.AbsoluteTreeRoot() : t:NERDTreeRoot let searchRoot = a:searchFromAbsoluteRoot ? s:TreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot
let targetNode = searchRoot.findNode(self.path) let targetNode = searchRoot.findNode(self.path)
if empty(targetNode) if empty(targetNode)
throw "NERDTree.BookmarkedNodeNotFound no node was found for bookmark: " . self.name throw "NERDTree.BookmarkedNodeNotFound no node was found for bookmark: " . self.name
@ -458,7 +458,7 @@ endfunction
function! s:TreeFileNode.copy(dest) function! s:TreeFileNode.copy(dest)
call self.path.copy(a:dest) call self.path.copy(a:dest)
let newPath = s:Path.New(a:dest) let newPath = s:Path.New(a:dest)
let parent = t:NERDTreeRoot.findNode(newPath.getParent()) let parent = b:NERDTreeRoot.findNode(newPath.getParent())
if !empty(parent) if !empty(parent)
call parent.refresh() call parent.refresh()
endif endif
@ -571,29 +571,29 @@ endfunction
"FUNCTION: TreeFileNode.isRoot() {{{3 "FUNCTION: TreeFileNode.isRoot() {{{3
"returns 1 if this node is t:NERDTreeRoot "returns 1 if this node is b:NERDTreeRoot
function! s:TreeFileNode.isRoot() function! s:TreeFileNode.isRoot()
if !s:treeExistsForTab() if !s:treeExistsForTab()
throw "NERDTree.TreeFileNode.IsRoot exception: No tree exists for the current tab" throw "NERDTree.TreeFileNode.IsRoot exception: No tree exists for the current tab"
endif endif
return self.equals(t:NERDTreeRoot) return self.equals(b:NERDTreeRoot)
endfunction endfunction
"FUNCTION: TreeFileNode.makeRoot() {{{3 "FUNCTION: TreeFileNode.makeRoot() {{{3
"Make this node the root of the tree "Make this node the root of the tree
function! s:TreeFileNode.makeRoot() function! s:TreeFileNode.makeRoot()
if self.path.isDirectory if self.path.isDirectory
let t:NERDTreeRoot = self let b:NERDTreeRoot = self
else else
call self.cacheParent() call self.cacheParent()
let t:NERDTreeRoot = self.parent let b:NERDTreeRoot = self.parent
endif endif
call t:NERDTreeRoot.open() call b:NERDTreeRoot.open()
"change dir to the dir of the new root if instructed to "change dir to the dir of the new root if instructed to
if g:NERDTreeChDirMode == 2 if g:NERDTreeChDirMode == 2
exec "cd " . t:NERDTreeRoot.path.strForEditCmd() exec "cd " . b:NERDTreeRoot.path.strForEditCmd()
endif endif
endfunction endfunction
"FUNCTION: TreeFileNode.New(path) {{{3 "FUNCTION: TreeFileNode.New(path) {{{3
@ -625,7 +625,7 @@ function! s:TreeFileNode.rename(newName)
call self.parent.removeChild(self) call self.parent.removeChild(self)
let parentPath = self.path.getPathTrunk() let parentPath = self.path.getPathTrunk()
let newParent = t:NERDTreeRoot.findNode(parentPath) let newParent = b:NERDTreeRoot.findNode(parentPath)
if newParent != {} if newParent != {}
call newParent.createChild(self.path, 1) call newParent.createChild(self.path, 1)
@ -652,7 +652,7 @@ let s:TreeDirNode = copy(s:TreeFileNode)
"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{3 "FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{3
"class method that returns the highest cached ancestor of the current root "class method that returns the highest cached ancestor of the current root
function! s:TreeDirNode.AbsoluteTreeRoot() function! s:TreeDirNode.AbsoluteTreeRoot()
let currentNode = t:NERDTreeRoot let currentNode = b:NERDTreeRoot
while currentNode.parent != {} while currentNode.parent != {}
let currentNode = currentNode.parent let currentNode = currentNode.parent
endwhile endwhile
@ -1342,7 +1342,7 @@ function! s:Path.ignore()
let lastPathComponent = self.getLastPathComponent(0) let lastPathComponent = self.getLastPathComponent(0)
"filter out the user specified paths to ignore "filter out the user specified paths to ignore
if t:NERDTreeIgnoreEnabled if b:NERDTreeIgnoreEnabled
for i in g:NERDTreeIgnore for i in g:NERDTreeIgnore
if lastPathComponent =~ i if lastPathComponent =~ i
return 1 return 1
@ -1351,11 +1351,11 @@ function! s:Path.ignore()
endif endif
"dont show hidden files unless instructed to "dont show hidden files unless instructed to
if t:NERDTreeShowHidden == 0 && lastPathComponent =~ '^\.' if b:NERDTreeShowHidden == 0 && lastPathComponent =~ '^\.'
return 1 return 1
endif endif
if t:NERDTreeShowFiles == 0 && self.isDirectory == 0 if b:NERDTreeShowFiles == 0 && self.isDirectory == 0
return 1 return 1
endif endif
@ -1702,30 +1702,32 @@ function! s:initNerdTree(name)
exec 'cd ' . path.strForCd() exec 'cd ' . path.strForCd()
endif endif
let t:treeShowHelp = 0
let t:NERDTreeIgnoreEnabled = 1
let t:NERDTreeShowFiles = g:NERDTreeShowFiles
let t:NERDTreeShowHidden = g:NERDTreeShowHidden
let t:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
if s:treeExistsForTab() if s:treeExistsForTab()
if s:isTreeOpen() if s:isTreeOpen()
call s:closeTree() call s:closeTree()
endif endif
unlet t:NERDTreeRoot unlet b:NERDTreeRoot
endif endif
let t:NERDTreeRoot = s:TreeDirNode.New(path) let newRoot = s:TreeDirNode.New(path)
call t:NERDTreeRoot.open() call newRoot.open()
call s:createTreeWin() call s:createTreeWin()
let b:treeShowHelp = 0
let b:NERDTreeIgnoreEnabled = 1
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
let b:NERDTreeRoot = newRoot
call s:renderView() call s:renderView()
call s:putCursorOnNode(t:NERDTreeRoot, 0, 0) call s:putCursorOnNode(b:NERDTreeRoot, 0, 0)
endfunction endfunction
" Function: s:treeExistsForTab() {{{2 " Function: s:treeExistsForTab() {{{2
" Returns 1 if a nerd tree root exists in the current tab " Returns 1 if a nerd tree root exists in the current tab
function! s:treeExistsForTab() function! s:treeExistsForTab()
return exists("t:NERDTreeRoot") return exists("t:NERDTreeBufName")
endfunction endfunction
" SECTION: Public Functions {{{1 " SECTION: Public Functions {{{1
"============================================================ "============================================================
@ -1821,8 +1823,10 @@ function! s:createTreeWin()
let splitLocation = (g:NERDTreeWinPos == "top" || g:NERDTreeWinPos == "left") ? "topleft " : "botright " let splitLocation = (g:NERDTreeWinPos == "top" || g:NERDTreeWinPos == "left") ? "topleft " : "botright "
let splitMode = s:shouldSplitVertically() ? "vertical " : "" let splitMode = s:shouldSplitVertically() ? "vertical " : ""
let splitSize = g:NERDTreeWinSize let splitSize = g:NERDTreeWinSize
let t:NERDTreeWinName = localtime() . s:NERDTreeWinName if !exists('t:NERDTreeBufName')
let cmd = splitLocation . splitMode . splitSize . ' new ' . t:NERDTreeWinName let t:NERDTreeBufName = localtime() . s:NERDTreeBufName
endif
let cmd = splitLocation . splitMode . splitSize . ' new ' . t:NERDTreeBufName
silent! execute cmd silent! execute cmd
setlocal winfixwidth setlocal winfixwidth
@ -1830,7 +1834,7 @@ function! s:createTreeWin()
"throwaway buffer options "throwaway buffer options
setlocal noswapfile setlocal noswapfile
setlocal buftype=nofile setlocal buftype=nofile
setlocal bufhidden=delete "setlocal bufhidden=delete
setlocal nowrap setlocal nowrap
setlocal foldcolumn=0 setlocal foldcolumn=0
setlocal nobuflisted setlocal nobuflisted
@ -1935,7 +1939,7 @@ endfunction
"prints out the quick help "prints out the quick help
function! s:dumpHelp() function! s:dumpHelp()
let old_h = @h let old_h = @h
if t:treeShowHelp == 1 if b:treeShowHelp == 1
let @h= "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n" let @h= "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n"
let @h=@h."\" ============================\n" let @h=@h."\" ============================\n"
let @h=@h."\" File node mappings~\n" let @h=@h."\" File node mappings~\n"
@ -1993,10 +1997,10 @@ function! s:dumpHelp()
let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Tree filtering mappings~\n" let @h=@h."\" Tree filtering mappings~\n"
let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (t:NERDTreeShowHidden ? "on" : "off") . ")\n" let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (t:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n" let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (t:NERDTreeShowFiles ? "on" : "off") . ")\n" let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (t:NERDTreeShowBookmarks ? "on" : "off") . ")\n" let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n"
let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Other mappings~\n" let @h=@h."\" Other mappings~\n"
@ -2059,7 +2063,7 @@ function! s:findNodeLineNumber(treenode)
let totalLines = line("$") let totalLines = line("$")
"the path components we have matched so far "the path components we have matched so far
let pathcomponents = [substitute(t:NERDTreeRoot.path.str(0), '/ *$', '', '')] let pathcomponents = [substitute(b:NERDTreeRoot.path.str(0), '/ *$', '', '')]
"the index of the component we are searching for "the index of the component we are searching for
let curPathComponent = 1 let curPathComponent = 1
@ -2137,7 +2141,7 @@ function! s:getPath(ln)
"check to see if we have the root node "check to see if we have the root node
if line =~ '^\/' if line =~ '^\/'
return t:NERDTreeRoot.path return b:NERDTreeRoot.path
endif endif
" in case called from outside the tree " in case called from outside the tree
@ -2146,7 +2150,7 @@ function! s:getPath(ln)
endif endif
if line == s:tree_up_dir_line if line == s:tree_up_dir_line
return t:NERDTreeRoot.path.getParent() return b:NERDTreeRoot.path.getParent()
endif endif
let indent = s:indentLevelFor(line) let indent = s:indentLevelFor(line)
@ -2183,7 +2187,7 @@ function! s:getPath(ln)
endif endif
endif endif
endwhile endwhile
let curFile = t:NERDTreeRoot.path.drive . dir . curFile let curFile = b:NERDTreeRoot.path.drive . dir . curFile
let toReturn = s:Path.New(curFile) let toReturn = s:Path.New(curFile)
return toReturn return toReturn
endfunction endfunction
@ -2223,7 +2227,7 @@ function! s:getSelectedNode()
if path == {} if path == {}
return {} return {}
endif endif
return t:NERDTreeRoot.findNode(path) return b:NERDTreeRoot.findNode(path)
catch /^NERDTree/ catch /^NERDTree/
return {} return {}
endtry endtry
@ -2231,8 +2235,8 @@ endfunction
"FUNCTION: s:getTreeWinNum() {{{2 "FUNCTION: s:getTreeWinNum() {{{2
"gets the nerd tree window number for this tab "gets the nerd tree window number for this tab
function! s:getTreeWinNum() function! s:getTreeWinNum()
if exists("t:NERDTreeWinName") if exists("t:NERDTreeBufName")
return bufwinnr(t:NERDTreeWinName) return bufwinnr(t:NERDTreeBufName)
else else
return -1 return -1
endif endif
@ -2455,7 +2459,7 @@ function! s:openNodeSplit(treenode)
"resize the tree window if no other window was open before "resize the tree window if no other window was open before
if onlyOneWin if onlyOneWin
let size = exists("t:NERDTreeOldWindowSize") ? t:NERDTreeOldWindowSize : g:NERDTreeWinSize let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
exec(there) exec(there)
exec("silent ". splitMode ." resize ". size) exec("silent ". splitMode ." resize ". size)
wincmd p wincmd p
@ -2484,7 +2488,7 @@ endfunction
"FUNCTION: s:putCursorOnBookmarkTable(){{{2 "FUNCTION: s:putCursorOnBookmarkTable(){{{2
"Places the cursor at the top of the bookmarks table "Places the cursor at the top of the bookmarks table
function! s:putCursorOnBookmarkTable() function! s:putCursorOnBookmarkTable()
if !t:NERDTreeShowBookmarks if !b:NERDTreeShowBookmarks
throw "NERDTree.IllegalOperation exception: cant find bookmark table, bookmarks arent active" throw "NERDTree.IllegalOperation exception: cant find bookmark table, bookmarks arent active"
endif endif
@ -2558,8 +2562,6 @@ endfunction
" "
"Args: "Args:
function! s:renderView() function! s:renderView()
execute s:getTreeWinNum() . "wincmd w"
setlocal modifiable setlocal modifiable
"remember the top line of the buffer and the current line so we can "remember the top line of the buffer and the current line so we can
@ -2577,7 +2579,7 @@ function! s:renderView()
call setline(line(".")+1, "") call setline(line(".")+1, "")
call cursor(line(".")+1, col(".")) call cursor(line(".")+1, col("."))
if t:NERDTreeShowBookmarks if b:NERDTreeShowBookmarks
call s:renderBookmarks() call s:renderBookmarks()
endif endif
@ -2586,11 +2588,11 @@ function! s:renderView()
call cursor(line(".")+1, col(".")) call cursor(line(".")+1, col("."))
"draw the header line "draw the header line
call setline(line(".")+1, t:NERDTreeRoot.path.str(0)) call setline(line(".")+1, b:NERDTreeRoot.path.str(0))
call cursor(line(".")+1, col(".")) call cursor(line(".")+1, col("."))
"draw the tree "draw the tree
call s:drawTree(t:NERDTreeRoot, 0, 0, [], t:NERDTreeRoot.getChildCount() == 1) call s:drawTree(b:NERDTreeRoot, 0, 0, [], b:NERDTreeRoot.getChildCount() == 1)
"delete the blank line at the top of the buffer "delete the blank line at the top of the buffer
silent 1,1delete _ silent 1,1delete _
@ -2631,16 +2633,16 @@ endfunction
" "
"Assumes the cursor is in the NERDTree window "Assumes the cursor is in the NERDTree window
function! s:restoreScreenState() function! s:restoreScreenState()
if !exists("t:NERDTreeOldTopLine") || !exists("t:NERDTreeOldPos") || !exists("t:NERDTreeOldWindowSize") if !exists("b:NERDTreeOldTopLine") || !exists("b:NERDTreeOldPos") || !exists("b:NERDTreeOldWindowSize")
return return
endif endif
exec("silent ". (s:shouldSplitVertically() ? "vertical" : "") ." resize ".t:NERDTreeOldWindowSize) exec("silent ". (s:shouldSplitVertically() ? "vertical" : "") ." resize ".b:NERDTreeOldWindowSize)
let old_scrolloff=&scrolloff let old_scrolloff=&scrolloff
let &scrolloff=0 let &scrolloff=0
call cursor(t:NERDTreeOldTopLine, 0) call cursor(b:NERDTreeOldTopLine, 0)
normal! zt normal! zt
call setpos(".", t:NERDTreeOldPos) call setpos(".", b:NERDTreeOldPos)
let &scrolloff=old_scrolloff let &scrolloff=old_scrolloff
endfunction endfunction
@ -2651,9 +2653,9 @@ function! s:saveScreenState()
let win = winnr() let win = winnr()
try try
call s:putCursorInTreeWin() call s:putCursorInTreeWin()
let t:NERDTreeOldPos = getpos(".") let b:NERDTreeOldPos = getpos(".")
let t:NERDTreeOldTopLine = line("w0") let b:NERDTreeOldTopLine = line("w0")
let t:NERDTreeOldWindowSize = s:shouldSplitVertically() ? winwidth("") : winheight("") let b:NERDTreeOldWindowSize = s:shouldSplitVertically() ? winwidth("") : winheight("")
exec win . "wincmd w" exec win . "wincmd w"
catch /NERDTree.view.InvalidOperation/ catch /NERDTree.view.InvalidOperation/
endtry endtry
@ -2803,8 +2805,6 @@ function! s:toggle(dir)
if s:treeExistsForTab() if s:treeExistsForTab()
if !s:isTreeOpen() if !s:isTreeOpen()
call s:createTreeWin() call s:createTreeWin()
call s:renderView()
call s:restoreScreenState() call s:restoreScreenState()
else else
call s:closeTree() call s:closeTree()
@ -2985,7 +2985,7 @@ function! s:chRoot()
call treenode.makeRoot() call treenode.makeRoot()
call s:renderView() call s:renderView()
call s:putCursorOnNode(t:NERDTreeRoot, 0, 0) call s:putCursorOnNode(b:NERDTreeRoot, 0, 0)
endfunction endfunction
" FUNCTION: s:clearBookmarks(bookmarks) {{{2 " FUNCTION: s:clearBookmarks(bookmarks) {{{2
@ -3153,7 +3153,7 @@ endfunction
" FUNCTION: s:displayHelp() {{{2 " FUNCTION: s:displayHelp() {{{2
" toggles the help display " toggles the help display
function! s:displayHelp() function! s:displayHelp()
let t:treeShowHelp = t:treeShowHelp ? 0 : 1 let b:treeShowHelp = b:treeShowHelp ? 0 : 1
call s:renderView() call s:renderView()
call s:centerView() call s:centerView()
endfunction endfunction
@ -3215,7 +3215,7 @@ function! s:insertNewNode()
try try
let newPath = s:Path.Create(newNodeName) let newPath = s:Path.Create(newNodeName)
let parentNode = t:NERDTreeRoot.findNode(newPath.getPathTrunk()) let parentNode = b:NERDTreeRoot.findNode(newPath.getPathTrunk())
let newTreeNode = s:TreeFileNode.New(newPath) let newTreeNode = s:TreeFileNode.New(newPath)
if parentNode.isOpen || !empty(parentNode.children) if parentNode.isOpen || !empty(parentNode.children)
@ -3259,7 +3259,7 @@ endfunction
" FUNCTION: s:jumpToRoot() {{{2 " FUNCTION: s:jumpToRoot() {{{2
" moves the cursor to the root node " moves the cursor to the root node
function! s:jumpToRoot() function! s:jumpToRoot()
call s:putCursorOnNode(t:NERDTreeRoot, 1, 0) call s:putCursorOnNode(b:NERDTreeRoot, 1, 0)
call s:centerView() call s:centerView()
endfunction endfunction
@ -3401,7 +3401,7 @@ endfunction
" will be reloaded. " will be reloaded.
function! s:refreshRoot() function! s:refreshRoot()
call s:echo("Refreshing the root node. This could take a while...") call s:echo("Refreshing the root node. This could take a while...")
call t:NERDTreeRoot.refresh() call b:NERDTreeRoot.refresh()
call s:renderView() call s:renderView()
redraw redraw
call s:echo("Refreshing the root node. This could take a while... DONE") call s:echo("Refreshing the root node. This could take a while... DONE")
@ -3501,7 +3501,7 @@ endfunction
" FUNCTION: s:toggleIgnoreFilter() {{{2 " FUNCTION: s:toggleIgnoreFilter() {{{2
" toggles the use of the NERDTreeIgnore option " toggles the use of the NERDTreeIgnore option
function! s:toggleIgnoreFilter() function! s:toggleIgnoreFilter()
let t:NERDTreeIgnoreEnabled = !t:NERDTreeIgnoreEnabled let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled
call s:renderViewSavingPosition() call s:renderViewSavingPosition()
call s:centerView() call s:centerView()
endfunction endfunction
@ -3509,8 +3509,8 @@ endfunction
" FUNCTION: s:toggleShowBookmarks() {{{2 " FUNCTION: s:toggleShowBookmarks() {{{2
" toggles the display of bookmarks " toggles the display of bookmarks
function! s:toggleShowBookmarks() function! s:toggleShowBookmarks()
let t:NERDTreeShowBookmarks = !t:NERDTreeShowBookmarks let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks
if t:NERDTreeShowBookmarks if b:NERDTreeShowBookmarks
call s:renderView() call s:renderView()
call s:putCursorOnBookmarkTable() call s:putCursorOnBookmarkTable()
else else
@ -3521,7 +3521,7 @@ endfunction
" FUNCTION: s:toggleShowFiles() {{{2 " FUNCTION: s:toggleShowFiles() {{{2
" toggles the display of hidden files " toggles the display of hidden files
function! s:toggleShowFiles() function! s:toggleShowFiles()
let t:NERDTreeShowFiles = !t:NERDTreeShowFiles let b:NERDTreeShowFiles = !b:NERDTreeShowFiles
call s:renderViewSavingPosition() call s:renderViewSavingPosition()
call s:centerView() call s:centerView()
endfunction endfunction
@ -3529,7 +3529,7 @@ endfunction
" FUNCTION: s:toggleShowHidden() {{{2 " FUNCTION: s:toggleShowHidden() {{{2
" toggles the display of hidden files " toggles the display of hidden files
function! s:toggleShowHidden() function! s:toggleShowHidden()
let t:NERDTreeShowHidden = !t:NERDTreeShowHidden let b:NERDTreeShowHidden = !b:NERDTreeShowHidden
call s:renderViewSavingPosition() call s:renderViewSavingPosition()
call s:centerView() call s:centerView()
endfunction endfunction
@ -3541,24 +3541,24 @@ endfunction
"keepState: 1 if the current root should be left open when the tree is "keepState: 1 if the current root should be left open when the tree is
"re-rendered "re-rendered
function! s:upDir(keepState) function! s:upDir(keepState)
let cwd = t:NERDTreeRoot.path.str(0) let cwd = b:NERDTreeRoot.path.str(0)
if cwd == "/" || cwd =~ '^[^/]..$' if cwd == "/" || cwd =~ '^[^/]..$'
call s:echo("already at top dir") call s:echo("already at top dir")
else else
if !a:keepState if !a:keepState
call t:NERDTreeRoot.close() call b:NERDTreeRoot.close()
endif endif
let oldRoot = t:NERDTreeRoot let oldRoot = b:NERDTreeRoot
if empty(t:NERDTreeRoot.parent) if empty(b:NERDTreeRoot.parent)
let path = t:NERDTreeRoot.path.getPathTrunk() let path = b:NERDTreeRoot.path.getPathTrunk()
let newRoot = s:TreeDirNode.New(path) let newRoot = s:TreeDirNode.New(path)
call newRoot.open() call newRoot.open()
call newRoot.transplantChild(t:NERDTreeRoot) call newRoot.transplantChild(b:NERDTreeRoot)
let t:NERDTreeRoot = newRoot let b:NERDTreeRoot = newRoot
else else
let t:NERDTreeRoot = t:NERDTreeRoot.parent let b:NERDTreeRoot = b:NERDTreeRoot.parent
endif endif