comparison src/testdir/test_autocmd.vim @ 31384:992bfd3aee3f v9.0.1025

patch 9.0.1025: WinScrolled is not triggered when filler lines change Commit: https://github.com/vim/vim/commit/3fc84dc2c7efecd7c14ce341cd777475058936fd Author: zeertzjq <zeertzjq@outlook.com> Date: Wed Dec 7 09:17:59 2022 +0000 patch 9.0.1025: WinScrolled is not triggered when filler lines change Problem: WinScrolled is not triggered when filler lines change. Solution: Add "topfill" to the values that WinScrolled triggers on. (closes #11668)
author Bram Moolenaar <Bram@vim.org>
date Wed, 07 Dec 2022 10:30:04 +0100
parents 49bd0e97549d
children 742b7bf2fefc
comparison
equal deleted inserted replaced
31383:15c80d8bc515 31384:992bfd3aee3f
391 call term_sendkeys(buf, "zlzh:echo g:scrolled\<CR>") 391 call term_sendkeys(buf, "zlzh:echo g:scrolled\<CR>")
392 call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000) 392 call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000)
393 393
394 let event = readfile('XscrollEvent')[0]->json_decode() 394 let event = readfile('XscrollEvent')[0]->json_decode()
395 call assert_equal({ 395 call assert_equal({
396 \ 'all': {'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, 'width': 0, 'height': 0, 'skipcol': 0} 397 \ '1000': {'leftcol': -1, 'topline': 0, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}
398 \ }, event) 398 \ }, event)
399 399
400 " Scroll up/down in Normal mode. 400 " Scroll up/down in Normal mode.
401 call term_sendkeys(buf, "\<c-e>\<c-y>:echo g:scrolled\<CR>") 401 call term_sendkeys(buf, "\<c-e>\<c-y>:echo g:scrolled\<CR>")
402 call WaitForAssert({-> assert_match('^4 ', term_getline(buf, 6))}, 1000) 402 call WaitForAssert({-> assert_match('^4 ', term_getline(buf, 6))}, 1000)
403 403
404 let event = readfile('XscrollEvent')[0]->json_decode() 404 let event = readfile('XscrollEvent')[0]->json_decode()
405 call assert_equal({ 405 call assert_equal({
406 \ 'all': {'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, 'width': 0, 'height': 0, 'skipcol': 0} 407 \ '1000': {'leftcol': 0, 'topline': -1, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}
408 \ }, event) 408 \ }, event)
409 409
410 " Scroll up/down in Insert mode. 410 " Scroll up/down in Insert mode.
411 call term_sendkeys(buf, "Mi\<c-x>\<c-e>\<Esc>i\<c-x>\<c-y>\<Esc>") 411 call term_sendkeys(buf, "Mi\<c-x>\<c-e>\<Esc>i\<c-x>\<c-y>\<Esc>")
412 call term_sendkeys(buf, ":echo g:scrolled\<CR>") 412 call term_sendkeys(buf, ":echo g:scrolled\<CR>")
413 call WaitForAssert({-> assert_match('^6 ', term_getline(buf, 6))}, 1000) 413 call WaitForAssert({-> assert_match('^6 ', term_getline(buf, 6))}, 1000)
414 414
415 let event = readfile('XscrollEvent')[0]->json_decode() 415 let event = readfile('XscrollEvent')[0]->json_decode()
416 call assert_equal({ 416 call assert_equal({
417 \ 'all': {'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, 'width': 0, 'height': 0, 'skipcol': 0} 418 \ '1000': {'leftcol': 0, 'topline': -1, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}
419 \ }, event) 419 \ }, event)
420 420
421 " Scroll the window horizontally to focus the last letter of the third line 421 " Scroll the window horizontally to focus the last letter of the third line
422 " containing only six characters. Moving to the previous and shorter lines 422 " containing only six characters. Moving to the previous and shorter lines
423 " should trigger another autocommand as Vim has to make them visible. 423 " should trigger another autocommand as Vim has to make them visible.
425 call term_sendkeys(buf, ":echo g:scrolled\<CR>") 425 call term_sendkeys(buf, ":echo g:scrolled\<CR>")
426 call WaitForAssert({-> assert_match('^8 ', term_getline(buf, 6))}, 1000) 426 call WaitForAssert({-> assert_match('^8 ', term_getline(buf, 6))}, 1000)
427 427
428 let event = readfile('XscrollEvent')[0]->json_decode() 428 let event = readfile('XscrollEvent')[0]->json_decode()
429 call assert_equal({ 429 call assert_equal({
430 \ 'all': {'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, 'width': 0, 'height': 0, 'skipcol': 0} 431 \ '1000': {'leftcol': -5, 'topline': 0, 'topfill': 0, 'width': 0, 'height': 0, 'skipcol': 0}
432 \ }, event) 432 \ }, event)
433 433
434 " Ensure the command was triggered for the specified window ID. 434 " Ensure the command was triggered for the specified window ID.
435 call term_sendkeys(buf, ":echo g:matched\<CR>") 435 call term_sendkeys(buf, ":echo g:matched\<CR>")
436 call WaitForAssert({-> assert_match('^v:true ', term_getline(buf, 6))}, 1000) 436 call WaitForAssert({-> assert_match('^v:true ', term_getline(buf, 6))}, 1000)
576 call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000) 576 call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000)
577 577
578 call term_sendkeys(buf, '$') 578 call term_sendkeys(buf, '$')
579 call term_sendkeys(buf, ":echo g:scrolled\<CR>") 579 call term_sendkeys(buf, ":echo g:scrolled\<CR>")
580 call WaitForAssert({-> assert_match('^3 ', term_getline(buf, 6))}, 1000) 580 call WaitForAssert({-> assert_match('^3 ', term_getline(buf, 6))}, 1000)
581
582 call StopVimInTerminal(buf)
583 endfunc
584
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)
581 641
582 call StopVimInTerminal(buf) 642 call StopVimInTerminal(buf)
583 endfunc 643 endfunc
584 644
585 func Test_WinClosed() 645 func Test_WinClosed()