Tidy up MouseFilter

This commit is contained in:
Ben Jackson 2021-01-09 10:45:27 +00:00
commit 31e44548d3

View file

@ -171,15 +171,20 @@ function! vimspector#internal#balloon#CreateTooltip(is_hover, ...)
augroup END augroup END
else else
" assume we are inside vim
func! MouseFilter(winid, key) func! MouseFilter(winid, key)
if index(["\<leftmouse>", "\<2-leftmouse>"], a:key) < 0
return 0
endif
let handled = 0 let handled = 0
if index(["\<leftmouse>", "\<2-leftmouse>"], a:key) >= 0
let mouse_coords = getmousepos() let mouse_coords = getmousepos()
" close the popup if mouse is clicked outside the window " close the popup if mouse is clicked outside the window
if mouse_coords['winid'] != a:winid if mouse_coords['winid'] != a:winid
call vimspector#internal#balloon#Close() call vimspector#internal#balloon#Close()
else return 0
endif
" place the cursor according to the click " place the cursor according to the click
call win_execute(a:winid, ":call cursor(".mouse_coords['line'].", ".mouse_coords['column'].")") call win_execute(a:winid, ":call cursor(".mouse_coords['line'].", ".mouse_coords['column'].")")
@ -190,8 +195,7 @@ function! vimspector#internal#balloon#CreateTooltip(is_hover, ...)
call py3eval("_vimspector_session.ExpandVariable(".line('.', a:winid).")") call py3eval("_vimspector_session.ExpandVariable(".line('.', a:winid).")")
let handled = 1 let handled = 1
endif endif
endif
endif
return handled return handled
endfunc endfunc