Skip to content

Commit c1b8160

Browse files
committed
patch 8.1.1216: mouse middle click is not tested
Problem: Mouse middle click is not tested. Solution: Add a test. (Dominique Pelle, closes #4310)
1 parent 49543fb commit c1b8160

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

src/testdir/test_termcodes.vim

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@ func MouseLeftClick(row, col)
2626
call TerminalEscapeCode(0x20, 0, a:row, a:col, 'M')
2727
endfunc
2828

29+
func MouseMiddleClick(row, col)
30+
call TerminalEscapeCode(0x21, 1, a:row, a:col, 'M')
31+
endfunc
32+
2933
func MouseLeftRelease(row, col)
3034
call TerminalEscapeCode(0x23, 3, a:row, a:col, 'm')
3135
endfunc
3236

37+
func MouseMiddleRelease(row, col)
38+
call TerminalEscapeCode(0x23, 3, a:row, a:col, 'm')
39+
endfunc
40+
3341
func MouseLeftDrag(row, col)
3442
call TerminalEscapeCode(0x43, 0x20, a:row, a:col, 'M')
3543
endfunc
@@ -42,7 +50,7 @@ func MouseWheelDown(row, col)
4250
call TerminalEscapeCode(0x41, 0x41, a:row, a:col, 'M')
4351
endfunc
4452

45-
func Test_xterm_mouse_click()
53+
func Test_xterm_mouse_left_click()
4654
new
4755
let save_mouse = &mouse
4856
let save_term = &term
@@ -68,6 +76,48 @@ func Test_xterm_mouse_click()
6876
bwipe!
6977
endfunc
7078

79+
func Test_xterm_mouse_middle_click()
80+
new
81+
let save_mouse = &mouse
82+
let save_term = &term
83+
let save_ttymouse = &ttymouse
84+
let save_quotestar = @*
85+
let @* = 'abc'
86+
set mouse=a term=xterm
87+
88+
for ttymouse_val in ['xterm2', 'sgr']
89+
let msg = 'ttymouse=' .. ttymouse_val
90+
exe 'set ttymouse=' . ttymouse_val
91+
call setline(1, ['123456789', '123456789'])
92+
93+
" Middle-click in the middle of the line pastes text where clicked.
94+
let row = 1
95+
let col = 6
96+
call MouseMiddleClick(row, col)
97+
call MouseMiddleRelease(row, col)
98+
call assert_equal(['12345abc6789', '123456789'], getline(1, '$'), msg)
99+
100+
" Middle-click beyond end of the line pastes text at the end of the line.
101+
let col = 20
102+
call MouseMiddleClick(row, col)
103+
call MouseMiddleRelease(row, col)
104+
call assert_equal(['12345abc6789abc', '123456789'], getline(1, '$'), msg)
105+
106+
" Middle-click beyond the last line pastes in the last line.
107+
let row = 5
108+
let col = 3
109+
call MouseMiddleClick(row, col)
110+
call MouseMiddleRelease(row, col)
111+
call assert_equal(['12345abc6789abc', '12abc3456789'], getline(1, '$'), msg)
112+
endfor
113+
114+
let &mouse = save_mouse
115+
let &term = save_term
116+
let &ttymouse = save_ttymouse
117+
let @* = save_quotestar
118+
bwipe!
119+
endfunc
120+
71121
func Test_xterm_mouse_wheel()
72122
new
73123
let save_mouse = &mouse

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ static char *(features[]) =
767767

768768
static int included_patches[] =
769769
{ /* Add new patch number below this line */
770+
/**/
771+
1216,
770772
/**/
771773
1215,
772774
/**/

0 commit comments

Comments
 (0)