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

Diagnostics fixes - hopefully only the non-controversial parts #4187

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions python/ycm/diagnostic_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def OnCursorMoved( self ):
if self._user_options[ 'echo_current_diagnostic' ]:
line, _ = vimsupport.CurrentLineAndColumn()
line += 1 # Convert to 1-based
if ( not self.ShouldUpdateDiagnosticsUINow() and
self._diag_message_needs_clearing ):
if not self.ShouldUpdateDiagnosticsUINow():
# Clear any previously echo'd diagnostic in insert mode
self._EchoDiagnosticText( line, None, None )
elif line != self._previous_diag_line_number:
Expand Down
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 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
37 changes: 33 additions & 4 deletions test/diagnostics.test.vim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function! Test_Disable_Diagnostics_Update_In_insert_Mode()

" Must do the checks in a timer callback because we need to stay in insert
" mode until done.
function! Check( id ) closure
function! CheckNoDiagUIAfterOpenParenthesis( id ) closure
call WaitForAssert( {->
\ assert_true(
\ py3eval(
Expand All @@ -62,10 +62,11 @@ function! Test_Disable_Diagnostics_Update_In_insert_Mode()
\ '%',
\ { 'group': 'ycm_signs' } )[ 0 ][ 'signs' ] ) ) } )

call FeedAndCheckAgain( " \<BS>\<BS>\<BS>", funcref( 'CheckAgain' ) )
call FeedAndCheckAgain( " \<BS>\<BS>\<BS>)",
\ funcref( 'CheckNoDiagUIAfterClosingPatenthesis' ) )
endfunction

function! CheckAgain( id ) closure
function! CheckNoDiagUIAfterClosingPatenthesis( id ) closure
call WaitForAssert( {->
\ assert_true(
\ py3eval(
Expand All @@ -76,9 +77,37 @@ function! Test_Disable_Diagnostics_Update_In_insert_Mode()
\ { 'group': 'ycm_signs' } )[ 0 ][ 'signs' ] ) ) } )

call feedkeys( "\<ESC>" )
call FeedAndCheckAgain( "\<ESC>",
\ funcref( 'CheckDiagUIRefreshedAfterLeavingInsertMode' ) )
endfunction

call FeedAndCheckMain( 'imain(', funcref( 'Check' ) )
function! CheckDiagUIRefreshedAfterLeavingInsertMode( id ) closure
call WaitForAssert( {->
\ assert_true(
\ py3eval(
\ 'len( ycm_state.CurrentBuffer()._diag_interface._diagnostics )'
\ ) ) } )
call WaitForAssert( {-> assert_true( len( sign_getplaced(
\ '%',
\ { 'group': 'ycm_signs' } )[ 0 ][ 'signs' ] ) ) } )
call FeedAndCheckAgain( "A\<CR>", funcref( 'CheckNoPropsAfterNewLine' )
endfunction

function! CheckNoPropsAfterNewLine( id ) closure
call WaitForAssert( {->
\ assert_true(
\ py3eval(
\ 'len( ycm_state.CurrentBuffer()._diag_interface._diagnostics )'
\ ) ) } )
call WaitForAssert( {-> assert_false( len( prop_list(
\ 1, { 'end_lnum': -1,
\ 'types': [ 'YcmVirtDiagWarning',
\ 'YcmVirtDiagError',
\ 'YcmVirtDiagPadding' ] } ) ) ) )
endfunction

call FeedAndCheckMain( 'imain(',
\ funcref( 'CheckNoDiagUIAfterOpenParenthesis' ) )
call test_override( 'ALL', 0 )
endfunction

Expand Down