mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-23 07:41:03 +08:00
Explicitly call open() in "ui_glue.vim" callbacks
This bug is subtle! Opening a directory node in a new tab (with the "t" or "T" mappings) would previously fail and require a refresh because it called the directory node's "activate()" method. In reviewing that method (i.e., "activate()"), I discovered that the directory node's NERDTree is rendered before the method returns, which overwrites the content of the tree in the new tab or window. To clarify, when "t" or "T" is used on a directory node, a new directory node and tree must be created to be rendered in a new tab. So, calling "self.getNerdtree().render()" at the bottom of "activate()" will render the NERDTree instance from which "t" or "T" was invoked, not the new NERDTree that is being displayed. This overwrites the new NERDTree text, and, thus, a refresh is required. Since a call to "render()" is almost always necessary at the bottom of "activate()" to keep everything in sync for other mappings, we avoid this problem entirely by using the "open()" method directly (works for files and directories) in the callbacks. Fixes #549.
This commit is contained in:
parent
0a0374b826
commit
ae1c95bcbc
|
@ -68,10 +68,10 @@ function! nerdtree#ui_glue#createDefaultBindings()
|
|||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Bookmark', 'callback': s . 'openInNewTab' })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Bookmark', 'callback': s . 'openInNewTabSilent' })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" })
|
||||
|
||||
|
@ -494,12 +494,12 @@ endfunction
|
|||
|
||||
" FUNCTION: s:openInNewTab(target) {{{1
|
||||
function! s:openInNewTab(target)
|
||||
call a:target.activate({'where': 't'})
|
||||
call a:target.open({'where': 't'})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openInNewTabSilent(target) {{{1
|
||||
function! s:openInNewTabSilent(target)
|
||||
call a:target.activate({'where': 't', 'stay': 1})
|
||||
call a:target.open({'where': 't', 'stay': 1})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openNodeRecursively(node) {{{1
|
||||
|
|
Loading…
Reference in New Issue
Block a user