Fix unstable behavior in "NERDTreeUI.getPath()"
This commit prevents "NERDTreeUI.getPath()" from returning a "Path" object even when no tree node was selected. Previously, positioning your cursor on one of the blank lines above the tree and running... :echo g:NERDTreeFileNode.GetSelected() ... could potentially return the path for the current working directory (your working directory needs to be under the tree root). This is because the constructor for "Path" objects returns a "Path" for the current working directory when passed an empty string. So, we need to short circuit the "getPath()" function for lines that cannot possibly be tree nodes. This solves the problem for "GetSelected()" because that method uses the "getPath()" method from the "UI" class to do its work. Note that this bug only presented for me on *nix systems.
This commit is contained in:
parent
1d14961285
commit
a019486dc8
@ -158,6 +158,10 @@ function! s:UI.getPath(ln)
|
||||
return self.nerdtree.root.path.getParent()
|
||||
endif
|
||||
|
||||
if a:ln < rootLine
|
||||
return {}
|
||||
endif
|
||||
|
||||
let indent = self._indentLevelFor(line)
|
||||
|
||||
" remove the tree parts and the leading space
|
||||
|
Loading…
Reference in New Issue
Block a user