From 5f5fc9cb11594da7df9570c28f1aa16f233c8dc4 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 8205d83eb9..dcf7e8655f 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 @@ -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