Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Fix] closing of collapsible directories in NERDTree plugin #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
Loading
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Fix] closing of collapsible directories in NERDTree plugin
The NERDTree plugin will under some conditions fail to close a
collapisble directory with the error message: "cannot close tree root".
This commit replaces the traversing logic for collapsible directories
when closing with the latest code from NERDTree.

To reproduce this error use 'g:NERDTreeCascadeSingleChildDir=0' and
'g:NERDTreeCascadeOpenSingleChildDir=1'. Then the following dir tree:

dir-a
    dir-b
        dir-c
dir-d

Go over dir-c and press "x" to close this node.
  • Loading branch information
juliuszint committed Jul 16, 2022
commit 3da6a02eb8b19c7ac2bbee764c0849442783096b
38 changes: 17 additions & 21 deletions 38 nerdtree_plugin/webdevicons.vim
Original file line number Diff line number Diff line change
Expand Up @@ -257,28 +257,24 @@ function! WebDevIconsNERDTreeMapCloseChildren(node)
endfunction

function! WebDevIconsNERDTreeMapCloseDir(node)
" continue with normal original logic:
let parent = a:node.parent
while g:NERDTreeCascadeOpenSingleChildDir && !parent.isRoot()
let childNodes = parent.getVisibleChildren()
if len(childNodes) == 1 && childNodes[0].path.isDirectory
let parent = parent.parent
else
break
endif
let l:parent = a:node.parent
while l:parent.isCascadable()
let l:parent = l:parent.parent
endwhile
if parent ==# {} || parent.isRoot()
call nerdtree#echo('cannot close tree root')
else
call parent.close()
" update the glyph
call WebDevIconsNERDTreeDirClose(parent)
call b:NERDTree.render()
call parent.putCursorHere(0, 0)
" glyph change possible artifact clean-up
if g:DevIconsEnableNERDTreeRedraw ==# 1
redraw!
endif

if l:parent.isRoot()
call nerdtree#echo('cannot close tree root')
return
endif

call parent.close()
" update the glyph
call WebDevIconsNERDTreeDirClose(parent)
call b:NERDTree.render()
call parent.putCursorHere(0, 0)
" glyph change possible artifact clean-up
if g:DevIconsEnableNERDTreeRedraw ==# 1
redraw!
endif
endfunction

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.