@@ -393,8 +393,8 @@ func Test_WinScrolled()
393393
394394 let event = readfile (' XscrollEvent' )[0 ]- >json_decode ()
395395 call assert_equal ({
396- \ ' all' : {' leftcol' : 1 , ' topline' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
397- \ ' 1000' : {' leftcol' : -1 , ' topline' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
396+ \ ' all' : {' leftcol' : 1 , ' topline' : 0 , ' topfill ' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
397+ \ ' 1000' : {' leftcol' : -1 , ' topline' : 0 , ' topfill ' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
398398 \ }, event )
399399
400400 " Scroll up/down in Normal mode.
@@ -403,8 +403,8 @@ func Test_WinScrolled()
403403
404404 let event = readfile (' XscrollEvent' )[0 ]- >json_decode ()
405405 call assert_equal ({
406- \ ' all' : {' leftcol' : 0 , ' topline' : 1 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
407- \ ' 1000' : {' leftcol' : 0 , ' topline' : -1 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
406+ \ ' all' : {' leftcol' : 0 , ' topline' : 1 , ' topfill ' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
407+ \ ' 1000' : {' leftcol' : 0 , ' topline' : -1 , ' topfill ' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
408408 \ }, event )
409409
410410 " Scroll up/down in Insert mode.
@@ -414,8 +414,8 @@ func Test_WinScrolled()
414414
415415 let event = readfile (' XscrollEvent' )[0 ]- >json_decode ()
416416 call assert_equal ({
417- \ ' all' : {' leftcol' : 0 , ' topline' : 1 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
418- \ ' 1000' : {' leftcol' : 0 , ' topline' : -1 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
417+ \ ' all' : {' leftcol' : 0 , ' topline' : 1 , ' topfill ' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
418+ \ ' 1000' : {' leftcol' : 0 , ' topline' : -1 , ' topfill ' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
419419 \ }, event )
420420
421421 " Scroll the window horizontally to focus the last letter of the third line
@@ -427,8 +427,8 @@ func Test_WinScrolled()
427427
428428 let event = readfile (' XscrollEvent' )[0 ]- >json_decode ()
429429 call assert_equal ({
430- \ ' all' : {' leftcol' : 5 , ' topline' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
431- \ ' 1000' : {' leftcol' : -5 , ' topline' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
430+ \ ' all' : {' leftcol' : 5 , ' topline' : 0 , ' topfill ' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
431+ \ ' 1000' : {' leftcol' : -5 , ' topline' : 0 , ' topfill ' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
432432 \ }, event )
433433
434434 " Ensure the command was triggered for the specified window ID.
@@ -582,6 +582,66 @@ func Test_WinScrolled_long_wrapped()
582582 call StopVimInTerminal (buf )
583583endfunc
584584
585+ func Test_WinScrolled_diff ()
586+ CheckRunVimInTerminal
587+
588+ let lines = << trim END
589+ set diffopt += foldcolumn :0
590+ call setline (1 , [' a' , ' b' , ' c' , ' d' , ' e' , ' f' , ' g' , ' h' , ' i' ])
591+ vnew
592+ call setline (1 , [' d' , ' e' , ' f' , ' g' , ' h' , ' i' ])
593+ windo diffthis
594+ func WriteScrollEvent ()
595+ call writefile ([json_encode (v: event )], ' XscrollEvent' )
596+ endfunc
597+ au WinScrolled * call WriteScrollEvent ()
598+ END
599+ call writefile (lines , ' Xtest_winscrolled_diff' , ' D' )
600+ let buf = RunVimInTerminal (' -S Xtest_winscrolled_diff' , {' rows' : 8 })
601+
602+ call term_sendkeys (buf , " \<C-E> " )
603+ call WaitForAssert ({- > assert_match (' ^d' , term_getline (buf , 3 ))}, 1000 )
604+
605+ let event = readfile (' XscrollEvent' )[0 ]- >json_decode ()
606+ call assert_equal ({
607+ \ ' all' : {' leftcol' : 0 , ' topline' : 1 , ' topfill' : 1 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
608+ \ ' 1000' : {' leftcol' : 0 , ' topline' : 1 , ' topfill' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
609+ \ ' 1001' : {' leftcol' : 0 , ' topline' : 0 , ' topfill' : -1 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
610+ \ }, event )
611+
612+ call term_sendkeys (buf , " 2\<C-E> " )
613+ call WaitForAssert ({- > assert_match (' ^f' , term_getline (buf , 3 ))}, 1000 )
614+
615+ let event = readfile (' XscrollEvent' )[0 ]- >json_decode ()
616+ call assert_equal ({
617+ \ ' all' : {' leftcol' : 0 , ' topline' : 2 , ' topfill' : 2 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
618+ \ ' 1000' : {' leftcol' : 0 , ' topline' : 2 , ' topfill' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
619+ \ ' 1001' : {' leftcol' : 0 , ' topline' : 0 , ' topfill' : -2 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
620+ \ }, event )
621+
622+ call term_sendkeys (buf , " \<C-E> " )
623+ call WaitForAssert ({- > assert_match (' ^g' , term_getline (buf , 3 ))}, 1000 )
624+
625+ let event = readfile (' XscrollEvent' )[0 ]- >json_decode ()
626+ call assert_equal ({
627+ \ ' all' : {' leftcol' : 0 , ' topline' : 2 , ' topfill' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
628+ \ ' 1000' : {' leftcol' : 0 , ' topline' : 1 , ' topfill' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
629+ \ ' 1001' : {' leftcol' : 0 , ' topline' : 1 , ' topfill' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
630+ \ }, event )
631+
632+ call term_sendkeys (buf , " 2\<C-Y> " )
633+ call WaitForAssert ({- > assert_match (' ^e' , term_getline (buf , 3 ))}, 1000 )
634+
635+ let event = readfile (' XscrollEvent' )[0 ]- >json_decode ()
636+ call assert_equal ({
637+ \ ' all' : {' leftcol' : 0 , ' topline' : 3 , ' topfill' : 1 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
638+ \ ' 1000' : {' leftcol' : 0 , ' topline' : -2 , ' topfill' : 0 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 },
639+ \ ' 1001' : {' leftcol' : 0 , ' topline' : -1 , ' topfill' : 1 , ' width' : 0 , ' height' : 0 , ' skipcol' : 0 }
640+ \ }, event )
641+
642+ call StopVimInTerminal (buf )
643+ endfunc
644+
585645func Test_WinClosed ()
586646 " Test that the pattern is matched against the closed window's ID, and both
587647 " <amatch> and <afile> are set to it.
0 commit comments