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 5, 2024
1 parent 1212def commit 5f5fc9c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 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 @@ -1621,9 +1627,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 5f5fc9c

Please sign in to comment.