@@ -760,12 +760,28 @@ function! s:OnFileSave()
760
760
endfunction
761
761
762
762
763
+ function ! s: AbortAutohoverRequest () abort
764
+ if g: ycm_auto_hover == # ' CursorHold' && s: enable_hover
765
+ let requests = copy ( s: pollers .command .requests )
766
+ for request_id in keys ( requests )
767
+ let request = requests[ request_id ]
768
+ if request.origin == ' autohover'
769
+ call remove ( s: pollers .command .requests, request_id )
770
+ call request.callback ( ' ' )
771
+ endif
772
+ endfor
773
+ endif
774
+ endfunction
775
+
776
+
763
777
function ! s: OnBufferEnter ()
764
778
call s: StartMessagePoll ()
765
779
if ! s: VisitedBufferRequiresReparse ()
766
780
return
767
781
endif
768
782
783
+ call s: AbortAutohoverRequest ()
784
+
769
785
call s: SetUpCompleteopt ()
770
786
call s: EnableCompletingInCurrentBuffer ()
771
787
@@ -966,6 +982,8 @@ function! s:OnCursorMovedNormalMode()
966
982
return
967
983
endif
968
984
985
+ call s: AbortAutohoverRequest ()
986
+
969
987
py3 ycm_state.OnCursorMoved ()
970
988
endfunction
971
989
@@ -1441,22 +1459,13 @@ function! youcompleteme#GetCommandResponse( ... ) abort
1441
1459
endfunction
1442
1460
1443
1461
1444
- function ! youcompleteme#GetCommandResponseAsync ( callback, ... ) abort
1445
- if ! s: AllowedToCompleteInCurrentBuffer ()
1446
- eval a: callback ( ' ' )
1447
- return
1448
- endif
1449
-
1450
- if ! get ( b: , ' ycm_completing' )
1451
- eval a: callback ( ' ' )
1452
- return
1453
- endif
1454
-
1462
+ function ! s: GetCommandResponseAsyncImpl ( callback, origin, ... ) abort
1455
1463
let request_id = py3eval (
1456
1464
\ ' ycm_state.SendCommandRequestAsync( vim.eval( "a:000" ) )' )
1457
1465
1458
1466
let s: pollers .command .requests[ request_id ] = {
1459
1467
\ ' response_func' : ' StringResponse' ,
1468
+ \ ' origin' : a: origin ,
1460
1469
\ ' callback' : a: callback
1461
1470
\ }
1462
1471
if s: pollers .command .id == -1
@@ -1466,6 +1475,21 @@ function! youcompleteme#GetCommandResponseAsync( callback, ... ) abort
1466
1475
endfunction
1467
1476
1468
1477
1478
+ function ! youcompleteme#GetCommandResponseAsync ( callback, ... ) abort
1479
+ if ! s: AllowedToCompleteInCurrentBuffer ()
1480
+ eval a: callback ( ' ' )
1481
+ return
1482
+ endif
1483
+
1484
+ if ! get ( b: , ' ycm_completing' )
1485
+ eval a: callback ( ' ' )
1486
+ return
1487
+ endif
1488
+
1489
+ call s: GetCommandResponseAsyncImpl ( callback, ' extern' , a: 000 )
1490
+ endfunction
1491
+
1492
+
1469
1493
function ! youcompleteme#GetRawCommandResponseAsync ( callback, ... ) abort
1470
1494
if ! s: AllowedToCompleteInCurrentBuffer ()
1471
1495
eval a: callback ( { ' error' : ' ycm not allowed in buffer' } )
@@ -1482,6 +1506,7 @@ function! youcompleteme#GetRawCommandResponseAsync( callback, ... ) abort
1482
1506
1483
1507
let s: pollers .command .requests[ request_id ] = {
1484
1508
\ ' response_func' : ' Response' ,
1509
+ \ ' origin' : ' extern_raw' ,
1485
1510
\ ' callback' : a: callback
1486
1511
\ }
1487
1512
if s: pollers .command .id == -1
@@ -1621,8 +1646,9 @@ if exists( '*popup_atcursor' )
1621
1646
return
1622
1647
endif
1623
1648
1624
- call youcompleteme#GetCommandResponseAsync (
1649
+ call s: GetCommandResponseAsyncImpl (
1625
1650
\ function ( ' s:ShowHoverResult' ),
1651
+ \ ' autohover' ,
1626
1652
\ b: ycm_hover .command )
1627
1653
endfunction
1628
1654
0 commit comments