diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-10-13 21:01:34 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-10-13 21:01:34 +0200 |
commit | 6aa7523b9642a752ab879131d4b159635207d9f2 (patch) | |
tree | ac5847eb09d81f13013576ce426d20e79d38edd1 | |
parent | 53efb18530cc3940d7af2ea338947783ea5495ed (diff) |
patch 8.1.2148: no test for right click extending Visual areav8.1.2148
Problem: No test for right click extending Visual area.
Solution: Add a test. (Dominique Pelle, closes #5018)
-rw-r--r-- | src/testdir/test_termcodes.vim | 87 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 88 insertions, 1 deletions
diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim index 8fe1850ebe..1a10d62577 100644 --- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -72,6 +72,14 @@ func MouseMiddleClick(row, col) endif endfunc +func MouseRightClick(row, col) + if &ttymouse ==# 'dec' + call DecEscapeCode(6, 1, a:row, a:col) + else + call TerminalEscapeCode(2, a:row, a:col, 'M') + endif +endfunc + func MouseCtrlLeftClick(row, col) let ctrl = 0x10 call TerminalEscapeCode(0 + ctrl, a:row, a:col, 'M') @@ -101,7 +109,11 @@ func MouseMiddleRelease(row, col) endfunc func MouseRightRelease(row, col) - call TerminalEscapeCode(3, a:row, a:col, 'm') + if &ttymouse ==# 'dec' + call DecEscapeCode(7, 0, a:row, a:col) + else + call TerminalEscapeCode(3, a:row, a:col, 'm') + endif endfunc func MouseLeftDrag(row, col) @@ -148,6 +160,79 @@ func Test_term_mouse_left_click() bwipe! endfunc +func Test_xterm_mouse_right_click_extends_visual() + if has('mac') + throw "Skipped: test right click in visual mode does not work on macOs (why?)" + endif + let save_mouse = &mouse + let save_term = &term + let save_ttymouse = &ttymouse + call test_override('no_query_mouse', 1) + set mouse=a term=xterm + + for visual_mode in ["v", "V", "\<C-V>"] + for ttymouse_val in s:ttymouse_values + s:ttymouse_dec + let msg = 'visual=' .. visual_mode .. ' ttymouse=' .. ttymouse_val + exe 'set ttymouse=' .. ttymouse_val + + call setline(1, repeat([repeat('-', 7)], 7)) + call MouseLeftClick(4, 4) + call MouseLeftRelease(4, 4) + exe "norm! " .. visual_mode + + " Right click extends top left of visual area. + call MouseRightClick(2, 2) + call MouseRightRelease(2, 2) + + " Right click extends bottom bottom right of visual area. + call MouseRightClick(6, 6) + call MouseRightRelease(6, 6) + norm! r1gv + + " Right click shrinks top left of visual area. + call MouseRightClick(3, 3) + call MouseRightRelease(3, 3) + + " Right click shrinks bottom right of visual area. + call MouseRightClick(5, 5) + call MouseRightRelease(5, 5) + norm! r2 + + if visual_mode ==# 'v' + call assert_equal(['-------', + \ '-111111', + \ '1122222', + \ '2222222', + \ '2222211', + \ '111111-', + \ '-------'], getline(1, '$'), msg) + elseif visual_mode ==# 'V' + call assert_equal(['-------', + \ '1111111', + \ '2222222', + \ '2222222', + \ '2222222', + \ '1111111', + \ '-------'], getline(1, '$'), msg) + else + call assert_equal(['-------', + \ '-11111-', + \ '-12221-', + \ '-12221-', + \ '-12221-', + \ '-11111-', + \ '-------'], getline(1, '$'), msg) + endif + endfor + endfor + + let &mouse = save_mouse + let &term = save_term + let &ttymouse = save_ttymouse + call test_override('no_query_mouse', 0) + bwipe! +endfunc + " Test that <C-LeftMouse> jumps to help tag and <C-RightMouse> jumps back. func Test_xterm_mouse_ctrl_click() let save_mouse = &mouse diff --git a/src/version.c b/src/version.c index 3dc64cc08d..cf6c773719 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2148, +/**/ 2147, /**/ 2146, |