Skip to content

Commit cc9a3ae

Browse files
authored
Merge pull request #4187 from bstaletic/diag-fixes-pt1
Diagnostics fixes - hopefully only the non-controversial parts
2 parents 88ed5a7 + 456b469 commit cc9a3ae

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

python/ycm/diagnostic_interface.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ def OnCursorMoved( self ):
4444
if self._user_options[ 'echo_current_diagnostic' ]:
4545
line, _ = vimsupport.CurrentLineAndColumn()
4646
line += 1 # Convert to 1-based
47-
if ( not self.ShouldUpdateDiagnosticsUINow() and
48-
self._diag_message_needs_clearing ):
47+
if not self.ShouldUpdateDiagnosticsUINow():
4948
# Clear any previously echo'd diagnostic in insert mode
5049
self._EchoDiagnosticText( line, None, None )
5150
elif line != self._previous_diag_line_number:

python/ycm/youcompleteme.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,10 @@ def OnInsertEnter( self ):
614614

615615

616616
def OnInsertLeave( self ):
617+
async_diags = any( self._message_poll_requests.get( filetype )
618+
for filetype in vimsupport.CurrentFiletypes() )
617619
if ( not self._user_options[ 'update_diagnostics_in_insert_mode' ] and
618-
not self.CurrentBuffer().ParseRequestPending() ):
620+
( async_diags or not self.CurrentBuffer().ParseRequestPending() ) ):
619621
self.CurrentBuffer().RefreshDiagnosticsUI()
620622
SendEventNotificationAsync( 'InsertLeave' )
621623

test/diagnostics.test.vim

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function! Test_Disable_Diagnostics_Update_In_insert_Mode()
5252

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

65-
call FeedAndCheckAgain( " \<BS>\<BS>\<BS>", funcref( 'CheckAgain' ) )
65+
call FeedAndCheckAgain( " \<BS>\<BS>\<BS>)",
66+
\ funcref( 'CheckNoDiagUIAfterClosingPatenthesis' ) )
6667
endfunction
6768

68-
function! CheckAgain( id ) closure
69+
function! CheckNoDiagUIAfterClosingPatenthesis( id ) closure
6970
call WaitForAssert( {->
7071
\ assert_true(
7172
\ py3eval(
@@ -76,9 +77,37 @@ function! Test_Disable_Diagnostics_Update_In_insert_Mode()
7677
\ { 'group': 'ycm_signs' } )[ 0 ][ 'signs' ] ) ) } )
7778

7879
call feedkeys( "\<ESC>" )
80+
call FeedAndCheckAgain( "\<ESC>",
81+
\ funcref( 'CheckDiagUIRefreshedAfterLeavingInsertMode' ) )
7982
endfunction
8083

81-
call FeedAndCheckMain( 'imain(', funcref( 'Check' ) )
84+
function! CheckDiagUIRefreshedAfterLeavingInsertMode( id ) closure
85+
call WaitForAssert( {->
86+
\ assert_true(
87+
\ py3eval(
88+
\ 'len( ycm_state.CurrentBuffer()._diag_interface._diagnostics )'
89+
\ ) ) } )
90+
call WaitForAssert( {-> assert_true( len( sign_getplaced(
91+
\ '%',
92+
\ { 'group': 'ycm_signs' } )[ 0 ][ 'signs' ] ) ) } )
93+
call FeedAndCheckAgain( "A\<CR>", funcref( 'CheckNoPropsAfterNewLine' )
94+
endfunction
95+
96+
function! CheckNoPropsAfterNewLine( id ) closure
97+
call WaitForAssert( {->
98+
\ assert_true(
99+
\ py3eval(
100+
\ 'len( ycm_state.CurrentBuffer()._diag_interface._diagnostics )'
101+
\ ) ) } )
102+
call WaitForAssert( {-> assert_false( len( prop_list(
103+
\ 1, { 'end_lnum': -1,
104+
\ 'types': [ 'YcmVirtDiagWarning',
105+
\ 'YcmVirtDiagError',
106+
\ 'YcmVirtDiagPadding' ] } ) ) ) )
107+
endfunction
108+
109+
call FeedAndCheckMain( 'imain(',
110+
\ funcref( 'CheckNoDiagUIAfterOpenParenthesis' ) )
82111
call test_override( 'ALL', 0 )
83112
endfunction
84113

0 commit comments

Comments
 (0)