# HG changeset patch # User Bram Moolenaar # Date 1554667204 -7200 # Node ID 7feb5b90be5f1ebb25140f499aef7dc7b1307373 # Parent c9aaabbfa62759e9e56ebce7b18d6f000bd06e03 patch 8.1.1137: xterm mouse wheel escape sequence is not tested commit https://github.com/vim/vim/commit/049736fa8af211886848d4a847b45d5d991c9687 Author: Bram Moolenaar Date: Sun Apr 7 21:55:07 2019 +0200 patch 8.1.1137: xterm mouse wheel escape sequence is not tested Problem: Xterm mouse wheel escape sequence is not tested. Solution: Add a test using low-level input. (Dominique Pelle, closes https://github.com/vim/vim/issues/4221) diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim --- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -45,3 +45,69 @@ func Test_xterm_mouse_click() bwipe! endfunc +func Test_xterm_mouse_wheel() + new + let save_mouse = &mouse + let save_term = &term + let save_ttymouse = &ttymouse + set mouse=a + set term=xterm + call setline(1, range(1, 100)) + + " Test Xterm mouse wheel. + set ttymouse=xterm + let button = 0x41 " wheel down. + let row = 1 + 32 " cursor position for mouse wheel is not relevant. + let col = 1 + 32 + + call assert_equal(1, line('w0')) + call assert_equal([0, 1, 1, 0], getpos('.')) + call feedkeys("\[M" .. list2str([button, col, row]), 'Lx!') + call assert_equal(4, line('w0')) + call assert_equal([0, 4, 1, 0], getpos('.')) + call feedkeys("\[M" .. list2str([button, col, row]), 'Lx!') + call assert_equal(7, line('w0')) + call assert_equal([0, 7, 1, 0], getpos('.')) + + let button = 0x40 " wheel up. + + call feedkeys("\[M" .. list2str([button, col, row]), 'Lx!') + call assert_equal(4, line('w0')) + call assert_equal([0, 7, 1, 0], getpos('.')) + call feedkeys("\[M" .. list2str([button, col, row]), 'Lx!') + call assert_equal(1, line('w0')) + call assert_equal([0, 7, 1, 0], getpos('.')) + + " Test SGR mouse wheel. + set ttymouse=sgr + go + let button = 0x41 " wheel down. + let row = 1 " cursor position for mouse wheel is not relevant. + let col = 1 + + call assert_equal(1, line('w0')) + call assert_equal([0, 1, 1, 0], getpos('.')) + call feedkeys(printf("\[<%d;%d;%dM", button, col, row), 'Lx!') + call assert_equal(4, line('w0')) + call assert_equal([0, 4, 1, 0], getpos('.')) + call feedkeys(printf("\[<%d;%d;%dM", button, col, row), 'Lx!') + call assert_equal(7, line('w0')) + call assert_equal([0, 7, 1, 0], getpos('.')) + + let button = 0x40 " wheel up. + + call feedkeys(printf("\[<%d;%d;%dM", button, col, row), 'Lx!') + call assert_equal(4, line('w0')) + call assert_equal([0, 7, 1, 0], getpos('.')) + call feedkeys(printf("\[<%d;%d;%dM", button, col, row), 'Lx!') + call assert_equal(1, line('w0')) + call assert_equal([0, 7, 1, 0], getpos('.')) + call feedkeys(printf("\[<%d;%d;%dM", button, col, row), 'Lx!') + call assert_equal(1, line('w0')) + call assert_equal([0, 7, 1, 0], getpos('.')) + + let &mouse = save_mouse + let &term = save_term + let &ttymouse = save_ttymouse + bwipe! +endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -772,6 +772,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1137, +/**/ 1136, /**/ 1135,