@@ -6,6 +6,7 @@ function! SetUp()
6
6
let g: ycm_log_level = ' DEBUG'
7
7
let g: ycm_always_populate_location_list = 1
8
8
let g: ycm_enable_semantic_highlighting = 1
9
+ let g: ycm_auto_hover = ' '
9
10
10
11
" diagnostics take ages
11
12
let g: ycm_test_min_delay = 7
@@ -348,15 +349,15 @@ function! Test_ShowDetailedDiagnostic_Popup_WithCharacters()
348
349
% bwipe!
349
350
endfunction
350
351
351
- function ! Test_ShowDetailedDiagnostic_Popup_MultilineDiag ()
352
+ function ! Test_ShowDetailedDiagnostic_Popup_MultilineDiagNotFromStartOfLine ()
352
353
let f = tempname () . ' .cc'
353
354
execut ' edit' f
354
355
call setline ( 1 , [
355
356
\ ' int main () {' ,
356
- \ ' const int && ' ,
357
- \ ' /* */ ' ,
358
- \ ' rd = 1; ' ,
359
- \ ' rd = 4 ;' ,
357
+ \ ' int a \ ' ,
358
+ \ ' =\ ' ,
359
+ \ ' = ' ,
360
+ \ ' 3 ;' ,
360
361
\ ' }' ,
361
362
\ ] )
362
363
call youcompleteme#test#setup#WaitForInitialParse ( {} )
@@ -367,62 +368,80 @@ function! Test_ShowDetailedDiagnostic_Popup_MultilineDiag()
367
368
\ ' len( ycm_state.CurrentBuffer()._diag_interface._diagnostics )'
368
369
\ ) ) } )
369
370
370
- " Start of multiline diagnostic.
371
- call cursor ( [ 2 , 1 ] )
372
- YcmShowDetailedDiagnostic popup
371
+ call test_override ( ' char_avail' , 1 )
373
372
374
- let popup_location = screenpos ( bufwinid ( ' %' ), 3 , 13 )
375
- let id = popup_locate ( popup_location[ ' row' ], popup_location[ ' col' ] )
376
- call assert_notequal ( 0 , id, " Couldn't find popup!" )
373
+ for cursor_pos in [ [ 2 , 9 ], [ 3 , 1 ], [ 4 , 1 ] ]
374
+ call cursor ( cursor_pos )
375
+ YcmShowDetailedDiagnostic popup
376
+
377
+ call assert_equal ( len ( popup_list () ), 1 )
378
+ let id = popup_list ()[ 0 ]
379
+ call assert_notequal ( 0 , id, " Couldn't find popup!" )
380
+ call assert_equal ( [ 3 , 10 ], win_screenpos ( id ) )
381
+
382
+ call youcompleteme#test#popup#CheckPopupPosition ( id, {
383
+ \ ' visible' : 1 ,
384
+ \ ' col' : 10 ,
385
+ \ ' line' : 3 ,
386
+ \ } )
387
+ call assert_match (
388
+ \ " ^Invalid '==' at end of declaration; did you mean '='?.*" ,
389
+ \ getbufline ( winbufnr (id), 1 , ' $' )[ 0 ] )
390
+ " From vim's test_popupwin.vim
391
+ " trigger the check for last_cursormoved by going into insert mode
392
+ call feedkeys ( " ji\<Esc> " , ' xt' )
393
+ call assert_equal ( {}, popup_getpos ( id ) )
394
+ endfor
377
395
378
- call youcompleteme#test#popup#CheckPopupPosition ( id, {
379
- \ ' visible' : 1 ,
380
- \ ' col' : 13 ,
381
- \ ' line' : 3 ,
382
- \ } )
383
- call assert_match (
384
- \ " ^Variable 'rd' declared const here.*" ,
385
- \ getbufline ( winbufnr (id), 1 , ' $' )[ 0 ] )
386
-
387
- " Middle of multiline diagnostic.
388
- call cursor ( [ 3 , 9 ] )
389
- YcmShowDetailedDiagnostic popup
396
+ call test_override ( ' ALL' , 0 )
390
397
391
- let popup_location = screenpos ( bufwinid ( ' %' ), 3 , 13 )
392
- let id = popup_locate ( popup_location[ ' row' ], popup_location[ ' col' ] )
393
- call assert_notequal ( 0 , id, " Couldn't find popup!" )
398
+ % bwipe!
399
+ endfunction
394
400
395
- " End of multiline diagnostic.
396
- call youcompleteme#test#popup#CheckPopupPosition ( id, {
397
- \ ' visible' : 1 ,
398
- \ ' col' : 13 ,
399
- \ ' line' : 3 ,
400
- \ } )
401
- call assert_match (
402
- \ " ^Variable 'rd' declared const here.*" ,
403
- \ getbufline ( winbufnr (id), 1 , ' $' )[ 0 ] )
401
+ function ! Test_ShowDetailedDiagnostic_Popup_MultilineDiagFromStartOfLine ()
402
+ let f = tempname () . ' .cc'
403
+ execut ' edit' f
404
+ call setline ( 1 , [
405
+ \ ' int main () {' ,
406
+ \ ' const int &&' ,
407
+ \ ' /* */' ,
408
+ \ ' rd = 1;' ,
409
+ \ ' rd = 4;' ,
410
+ \ ' }' ,
411
+ \ ] )
412
+ call youcompleteme#test#setup#WaitForInitialParse ( {} )
404
413
405
- call cursor ( [ 4 , 5 ] )
406
- YcmShowDetailedDiagnostic popup
414
+ call WaitForAssert ( {- >
415
+ \ assert_true (
416
+ \ py3eval (
417
+ \ ' len( ycm_state.CurrentBuffer()._diag_interface._diagnostics )'
418
+ \ ) ) } )
407
419
408
- let popup_location = screenpos ( bufwinid ( ' %' ), 3 , 13 )
409
- let id = popup_locate ( popup_location[ ' row' ], popup_location[ ' col' ] )
410
- call assert_notequal ( 0 , id, " Couldn't find popup!" )
420
+ call test_override ( ' char_avail' , 1 )
411
421
412
- call youcompleteme#test#popup#CheckPopupPosition ( id, {
413
- \ ' visible' : 1 ,
414
- \ ' col' : 13 ,
415
- \ ' line' : 3 ,
416
- \ } )
417
- call assert_match (
418
- \ " ^Variable 'rd' declared const here.*" ,
419
- \ getbufline ( winbufnr (id), 1 , ' $' )[ 0 ] )
422
+ for cursor_pos in [ [ 2 , 1 ], [ 3 , 9 ], [ 4 , 5 ] ]
423
+ call cursor ( cursor_pos )
424
+ YcmShowDetailedDiagnostic popup
425
+
426
+ call assert_equal ( 1 , len ( popup_list () ) )
427
+ let id = popup_list ()[ 0 ]
428
+ call assert_notequal ( 0 , id, " Couldn't find popup!" )
429
+ call assert_equal ( [ 3 , 13 ], win_screenpos ( id ) )
430
+
431
+ call youcompleteme#test#popup#CheckPopupPosition ( id, {
432
+ \ ' visible' : 1 ,
433
+ \ ' col' : 13 ,
434
+ \ ' line' : 3 ,
435
+ \ } )
436
+ call assert_match (
437
+ \ " ^Variable 'rd' declared const here.*" ,
438
+ \ getbufline ( winbufnr (id), 1 , ' $' )[ 0 ] )
439
+ " From vim's test_popupwin.vim
440
+ " trigger the check for last_cursormoved by going into insert mode
441
+ call feedkeys ( " ji\<Esc> ki\<Esc> " , ' xt' )
442
+ call assert_equal ( {}, popup_getpos ( id ) )
443
+ endfor
420
444
421
- " From vim's test_popupwin.vim
422
- " trigger the check for last_cursormoved by going into insert mode
423
- call test_override ( ' char_avail' , 1 )
424
- call feedkeys ( " ji\<Esc> " , ' xt' )
425
- call assert_equal ( {}, popup_getpos ( id ) )
426
445
call test_override ( ' ALL' , 0 )
427
446
428
447
% bwipe!
0 commit comments