Skip to content

Commit

Permalink
Handle scrolling when hover popup is open
Browse files Browse the repository at this point in the history
There are two kinds of scrolling that need to be handled:
1. Scrolling the buffer in a window shifts the buffer, but popups stay
   in place. Instead, we close the popup whenever we receive a
   WinScrolled event.
2. Scrolling the popup contents themselves resets the `updatetime` timer
   and can trigger a second CursorHold event, which leads to YCM
   resetting the hover popup. Instead, only re-display the hover popup
   if it is not already visible.
  • Loading branch information
bstaletic committed Jan 2, 2024
1 parent 71166ea commit 6f1c402
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions autoload/youcompleteme.vim
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ function! s:EnableAutoHover()
augroup YcmBufHover
autocmd! * <buffer>
autocmd CursorHold <buffer> call s:Hover()
autocmd WinScrolled <buffer> call popup_close( s:cursorhold_popup )
augroup END
endif
endfunction
Expand Down Expand Up @@ -1621,9 +1622,11 @@ if exists( '*popup_atcursor' )
return
endif

call youcompleteme#GetCommandResponseAsync(
\ function( 's:ShowHoverResult' ),
\ b:ycm_hover.command )
if empty( popup_getpos( s:cursorhold_popup ) )
call youcompleteme#GetCommandResponseAsync(
\ function( 's:ShowHoverResult' ),
\ b:ycm_hover.command )
endif
endfunction


Expand Down

0 comments on commit 6f1c402

Please sign in to comment.