Skip to content

Commit

Permalink
Make sure to refresh diagnostic UI on InsertLeave
Browse files Browse the repository at this point in the history
In case the current filetype language server uses LSP async diagnostics,
we might not get a reparse on InsertLeave. This happens if the user
leaves insert mode after a semantic trigger.

We would still try sending a FileReadyToParse request, but the diags get
ignored, because:

a) The filetype is known to use async diags.
b) We do not insist on a synchronous diag update, like :YcmDiags.

The solution is to check if the current filetype uses async diagnostics
and, if so, let InsertLeave refresh diagnostic UI regardless of what the
state of FileReadyToParse request is.

Note that this solution makes the flicker on leaving insert mode harder
to fix. Not only does OnCursorMoved cause a refresh of stale
diagnostics, but so does OnInsertLeave.
  • Loading branch information
bstaletic committed Sep 19, 2023
1 parent 75bb540 commit 2292370
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/ycm/youcompleteme.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,10 @@ def OnInsertEnter( self ):


def OnInsertLeave( self ):
async_diags = any( self._message_poll_requests.get( filetype )

Check warning on line 617 in python/ycm/youcompleteme.py

View check run for this annotation

Codecov / codecov/patch

python/ycm/youcompleteme.py#L617

Added line #L617 was not covered by tests
for filetype in vimsupport.CurrentFiletypes() )
if ( not self._user_options[ 'update_diagnostics_in_insert_mode' ] and
not self.CurrentBuffer().ParseRequestPending() ):
( async_diags or not self.CurrentBuffer().ParseRequestPending() ) ):
self.CurrentBuffer().RefreshDiagnosticsUI()
SendEventNotificationAsync( 'InsertLeave' )

Expand Down

0 comments on commit 2292370

Please sign in to comment.