Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[READY] Stop auto hover timer if buffer changes or cursor moves #4193

Merged
merged 1 commit into from Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 38 additions & 12 deletions autoload/youcompleteme.vim
Expand Up @@ -760,12 +760,28 @@
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( '' )

Check warning on line 770 in autoload/youcompleteme.vim

View check run for this annotation

Codecov / codecov/patch

autoload/youcompleteme.vim#L767-L770

Added lines #L767 - L770 were not covered by tests
endif
endfor
endif
endfunction


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

call s:AbortAutohoverRequest()

Check warning on line 783 in autoload/youcompleteme.vim

View check run for this annotation

Codecov / codecov/patch

autoload/youcompleteme.vim#L783

Added line #L783 was not covered by tests

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

Expand Down Expand Up @@ -966,6 +982,8 @@
return
endif

call s:AbortAutohoverRequest()

py3 ycm_state.OnCursorMoved()
endfunction

Expand Down Expand Up @@ -1441,22 +1459,13 @@
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 @@
endfunction


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

Check warning on line 1481 in autoload/youcompleteme.vim

View check run for this annotation

Codecov / codecov/patch

autoload/youcompleteme.vim#L1479-L1481

Added lines #L1479 - L1481 were not covered by tests
endif

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

Check warning on line 1486 in autoload/youcompleteme.vim

View check run for this annotation

Codecov / codecov/patch

autoload/youcompleteme.vim#L1484-L1486

Added lines #L1484 - L1486 were not covered by tests
endif

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

Check warning on line 1489 in autoload/youcompleteme.vim

View check run for this annotation

Codecov / codecov/patch

autoload/youcompleteme.vim#L1489

Added line #L1489 was not covered by tests
endfunction


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

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 @@
return
endif

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

Expand Down