Add a note/warning to "TreeDirNode.activate()"

This warning makes developers aware of the possibility of
overwriting the NERDTree text in a new window when activate is used.
This commit is contained in:
Jason Franklin 2017-11-11 13:23:51 -05:00
parent e27cd86a9b
commit 4c409a1640

View File

@ -21,12 +21,19 @@ function! s:TreeDirNode.AbsoluteTreeRoot()
endfunction
" FUNCTION: TreeDirNode.activate([options]) {{{1
unlet s:TreeDirNode.activate
function! s:TreeDirNode.activate(...)
let opts = a:0 ? a:1 : {}
call self.toggleOpen(opts)
call self.getNerdtree().render()
call self.putCursorHere(0, 0)
let l:options = (a:0 > 0) ? a:1 : {}
call self.toggleOpen(l:options)
" Note that we only re-render the NERDTree for this node if we did NOT
" create a new node and render it in a new window or tab. In the latter
" case, rendering the NERDTree for this node could overwrite the text of
" the new NERDTree!
if !has_key(l:options, 'where') || empty(l:options['where'])
call self.getNerdtree().render()
call self.putCursorHere(0, 0)
endif
endfunction
" FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{1