Skip to content

Commit

Permalink
Add tests for diagnostics clearing in insert mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bstaletic committed Oct 6, 2023
1 parent 1d15b86 commit 456b469
Showing 1 changed file with 33 additions and 4 deletions.
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

0 comments on commit 456b469

Please sign in to comment.