diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-04-28 14:45:12 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-04-28 16:43:38 +0800 |
commit | dda5cddbefa44ad6ca1ad5e85be65c3bbf109038 (patch) | |
tree | e67f104c83392804fc3fec9e8fe3775149f330b5 | |
parent | d857448466e686eb38d8cae3d478c8d2e6e2f44a (diff) | |
download | rneovim-dda5cddbefa44ad6ca1ad5e85be65c3bbf109038.tar.gz rneovim-dda5cddbefa44ad6ca1ad5e85be65c3bbf109038.tar.bz2 rneovim-dda5cddbefa44ad6ca1ad5e85be65c3bbf109038.zip |
vim-patch:8.1.2106: no tests for dragging the mouse beyond the window
Problem: No tests for dragging the mouse beyond the window.
Solution: Add a test. (Dominique Pelle, closes vim/vim#5004)
https://github.com/vim/vim/commit/b4367b7fb65f6a88f76ef99f79342341af0b1017
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | test/old/testdir/test_termcodes.vim | 92 |
1 files changed, 90 insertions, 2 deletions
diff --git a/test/old/testdir/test_termcodes.vim b/test/old/testdir/test_termcodes.vim index d4ac607bcc..2249a56bd4 100644 --- a/test/old/testdir/test_termcodes.vim +++ b/test/old/testdir/test_termcodes.vim @@ -56,13 +56,13 @@ func Test_xterm_mouse_ctrl_click() call MouseCtrlLeftClick(row, col) call MouseLeftRelease(row, col) call assert_match('usr_02.txt$', bufname('%'), msg) - call assert_equal('*usr_02.txt*', expand('<cWORD>')) + call assert_equal('*usr_02.txt*', expand('<cWORD>'), msg) call MouseCtrlRightClick(row, col) call MouseRightRelease(row, col) " call assert_match('help.txt$', bufname('%'), msg) call assert_match('usr_toc.txt$', bufname('%'), msg) - call assert_equal('|usr_02.txt|', expand('<cWORD>')) + call assert_equal('|usr_02.txt|', expand('<cWORD>'), msg) helpclose endfor @@ -160,6 +160,94 @@ func Test_1xterm_mouse_wheel() bwipe! endfunc +" Test that dragging beyond the window (at the bottom and at the top) +" scrolls window content by the number of of lines beyond the window. +func Test_term_mouse_drag_beyond_window() + let save_mouse = &mouse + let save_term = &term + " let save_ttymouse = &ttymouse + " call test_override('no_query_mouse', 1) + " set mouse=a term=xterm + set mouse=a + let col = 1 + call setline(1, range(1, 100)) + + " Split into 3 windows, and go into the middle window + " so we test dragging mouse below and above the window. + 2split + wincmd j + 2split + + for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec + let msg = 'ttymouse=' .. ttymouse_val + " exe 'set ttymouse=' .. ttymouse_val + + " Line #10 at the top. + norm! 10zt + redraw + call assert_equal(10, winsaveview().topline, msg) + call assert_equal(2, winheight(0), msg) + + let row = 4 + call MouseLeftClick(row, col) + call assert_equal(10, winsaveview().topline, msg) + + " Drag downwards. We're still in the window so topline should + " not change yet. + let row += 1 + call MouseLeftDrag(row, col) + call assert_equal(10, winsaveview().topline, msg) + + " We now leave the window at the bottom, so the window content should + " scroll by 1 line, then 2 lines (etc) as we drag further away. + let row += 1 + call MouseLeftDrag(row, col) + call assert_equal(11, winsaveview().topline, msg) + + let row += 1 + call MouseLeftDrag(row, col) + call assert_equal(13, winsaveview().topline, msg) + + " Now drag upwards. + let row -= 1 + call MouseLeftDrag(row, col) + call assert_equal(14, winsaveview().topline, msg) + + " We're now back in the window so the topline should not change. + let row -= 1 + call MouseLeftDrag(row, col) + call assert_equal(14, winsaveview().topline, msg) + + let row -= 1 + call MouseLeftDrag(row, col) + call assert_equal(14, winsaveview().topline, msg) + + " We now leave the window at the top so the window content should + " scroll by 1 line, then 2, then 3 (etc) in the opposite direction. + let row -= 1 + call MouseLeftDrag(row, col) + call assert_equal(13, winsaveview().topline, msg) + + let row -= 1 + call MouseLeftDrag(row, col) + call assert_equal(11, winsaveview().topline, msg) + + let row -= 1 + call MouseLeftDrag(row, col) + call assert_equal(8, winsaveview().topline, msg) + + call MouseLeftRelease(row, col) + call assert_equal(8, winsaveview().topline, msg) + call assert_equal(2, winheight(0), msg) + endfor + + let &mouse = save_mouse + " let &term = save_term + " let &ttymouse = save_ttymouse + " call test_override('no_query_mouse', 0) + bwipe! +endfunc + func Test_term_mouse_drag_window_separator() let save_mouse = &mouse let save_term = &term |