Merge pull request #711 from lifecrisis/issue650

BUGFIX: Broken middle click listener repaired.
This commit is contained in:
Phil Runninger 2017-06-19 23:49:38 -04:00 committed by GitHub
commit 54b423e0f8

View File

@ -7,7 +7,7 @@ let g:loaded_nerdtree_ui_glue_autoload = 1
function! nerdtree#ui_glue#createDefaultBindings()
let s = '<SNR>' . s:SID() . '_'
call NERDTreeAddKeyMap({ 'key': '<MiddleRelease>', 'scope': "all", 'callback': s."handleMiddleMouse" })
call NERDTreeAddKeyMap({ 'key': '<MiddleMouse>', 'scope': 'all', 'callback': s . 'handleMiddleMouse' })
call NERDTreeAddKeyMap({ 'key': '<LeftRelease>', 'scope': "all", 'callback': s."handleLeftClick" })
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" })
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" })
@ -336,16 +336,22 @@ endfunction
" FUNCTION: s:handleMiddleMouse() {{{1
function! s:handleMiddleMouse()
let curNode = g:NERDTreeFileNode.GetSelected()
if curNode ==# {}
call nerdtree#echo("Put the cursor on a node first" )
" A middle mouse click does not automatically position the cursor as one
" would expect. Forcing the execution of a regular left mouse click here
" fixes this problem.
execute "normal! \<LeftMouse>"
let l:currentNode = g:NERDTreeFileNode.GetSelected()
if empty(l:currentNode)
call nerdtree#echoError('use the pointer to select a node')
return
endif
if curNode.path.isDirectory
call nerdtree#openExplorer(curNode)
if l:currentNode.path.isDirectory
call l:currentNode.openExplorer()
else
call curNode.open({'where': 'h'})
call l:currentNode.open({'where': 'h'})
endif
endfunction