Skip to content

Commit

Permalink
Merge pull request #4193 from bstaletic/hover-traceback
Browse files Browse the repository at this point in the history
[READY] Stop auto hover timer if buffer changes or cursor moves
  • Loading branch information
mergify[bot] committed Feb 14, 2024
2 parents 1212def + 36a1a54 commit 05bbb07
Showing 1 changed file with 38 additions and 12 deletions.
50 changes: 38 additions & 12 deletions autoload/youcompleteme.vim
Expand Up @@ -760,12 +760,28 @@ function! s:OnFileSave()
endfunction


function! s:AbortAutohoverRequest() abort
if g:ycm_auto_hover ==# 'CursorHold' && s:enable_hover
let requests = copy( s:pollers.command.requests )
for request_id in keys( requests )
let request = requests[ request_id ]
if request.origin == 'autohover'
call remove( s:pollers.command.requests, request_id )
call request.callback( '' )
endif
endfor
endif
endfunction


function! s:OnBufferEnter()
call s:StartMessagePoll()
if !s:VisitedBufferRequiresReparse()
return
endif

call s:AbortAutohoverRequest()

call s:SetUpCompleteopt()
call s:EnableCompletingInCurrentBuffer()

Expand Down Expand Up @@ -966,6 +982,8 @@ function! s:OnCursorMovedNormalMode()
return
endif

call s:AbortAutohoverRequest()

py3 ycm_state.OnCursorMoved()
endfunction

Expand Down Expand Up @@ -1441,22 +1459,13 @@ function! youcompleteme#GetCommandResponse( ... ) abort
endfunction


function! youcompleteme#GetCommandResponseAsync( callback, ... ) abort
if !s:AllowedToCompleteInCurrentBuffer()
eval a:callback( '' )
return
endif

if !get( b:, 'ycm_completing' )
eval a:callback( '' )
return
endif

function! s:GetCommandResponseAsyncImpl( callback, origin, ... ) abort
let request_id = py3eval(
\ 'ycm_state.SendCommandRequestAsync( vim.eval( "a:000" ) )' )

let s:pollers.command.requests[ request_id ] = {
\ 'response_func': 'StringResponse',
\ 'origin': a:origin,
\ 'callback': a:callback
\ }
if s:pollers.command.id == -1
Expand All @@ -1466,6 +1475,21 @@ function! youcompleteme#GetCommandResponseAsync( callback, ... ) abort
endfunction


function! youcompleteme#GetCommandResponseAsync( callback, ... ) abort
if !s:AllowedToCompleteInCurrentBuffer()
eval a:callback( '' )
return
endif

if !get( b:, 'ycm_completing' )
eval a:callback( '' )
return
endif

call s:GetCommandResponseAsyncImpl( callback, 'extern', a:000 )
endfunction


function! youcompleteme#GetRawCommandResponseAsync( callback, ... ) abort
if !s:AllowedToCompleteInCurrentBuffer()
eval a:callback( { 'error': 'ycm not allowed in buffer' } )
Expand All @@ -1482,6 +1506,7 @@ function! youcompleteme#GetRawCommandResponseAsync( callback, ... ) abort

let s:pollers.command.requests[ request_id ] = {
\ 'response_func': 'Response',
\ 'origin': 'extern_raw',
\ 'callback': a:callback
\ }
if s:pollers.command.id == -1
Expand Down Expand Up @@ -1621,8 +1646,9 @@ if exists( '*popup_atcursor' )
return
endif

call youcompleteme#GetCommandResponseAsync(
call s:GetCommandResponseAsyncImpl(
\ function( 's:ShowHoverResult' ),
\ 'autohover',
\ b:ycm_hover.command )
endfunction

Expand Down

0 comments on commit 05bbb07

Please sign in to comment.