From cd48033263082142d139667ccd9a4cc50edd102f Mon Sep 17 00:00:00 2001 From: Boris Staletic Date: Tue, 2 Jan 2024 13:06:25 +0100 Subject: [PATCH] Handle scrolling when hover popup is open 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. --- autoload/youcompleteme.vim | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index fa85ed614..0e137506e 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -717,6 +717,12 @@ function! s:EnableAutoHover() augroup YcmBufHover autocmd! * autocmd CursorHold call s:Hover() + if exists( '##WinResized' ) + autocmd WinResized call popup_close( s:cursorhold_popup ) + endif + if exists( '##WinScrolled' ) + autocmd WinScrolled call popup_close( s:cursorhold_popup ) + endif augroup END endif endfunction @@ -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