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 Feb 14, 2024
1 parent 05bbb07 commit cd48033
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions autoload/youcompleteme.vim
Expand Up @@ -717,6 +717,12 @@ function! s:EnableAutoHover()
augroup YcmBufHover
autocmd! * <buffer>
autocmd CursorHold <buffer> call s:Hover()
if exists( '##WinResized' )
autocmd WinResized <buffer> call popup_close( s:cursorhold_popup )

Check warning on line 721 in autoload/youcompleteme.vim

View check run for this annotation

Codecov / codecov/patch

autoload/youcompleteme.vim#L721

Added line #L721 was not covered by tests
endif
if exists( '##WinScrolled' )
autocmd WinScrolled <buffer> call popup_close( s:cursorhold_popup )
endif
augroup END
endif
endfunction
Expand Down Expand Up @@ -1646,10 +1652,12 @@ if exists( '*popup_atcursor' )
return
endif

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


Expand Down

0 comments on commit cd48033

Please sign in to comment.