Mercurial > vim
comparison src/testdir/test_termcodes.vim @ 16324:6b2412d0509f v8.1.1167
patch 8.1.1167: no test for closing tab by click in tabline
commit https://github.com/vim/vim/commit/39f76c6ac0f5e07a0e608ddf920a67702ec83824
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 13 22:13:23 2019 +0200
patch 8.1.1167: no test for closing tab by click in tabline
Problem: No test for closing tab by click in tabline.
Solution: Add a test. Also fix that dragging window separator could fail in
a large terminal. (Dominique Pelle, closes #4253)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 13 Apr 2019 22:15:04 +0200 |
parents | 57e0f6b4a87d |
children | 2f70fc41ff7e |
comparison
equal
deleted
inserted
replaced
16323:b8fcb5017058 | 16324:6b2412d0509f |
---|---|
117 split | 117 split |
118 let rowseparator = winheight(0) + 1 | 118 let rowseparator = winheight(0) + 1 |
119 let row = rowseparator | 119 let row = rowseparator |
120 let col = 1 | 120 let col = 1 |
121 | 121 |
122 if ttymouse_val ==# 'xterm' && row > 223 | 122 " When 'ttymouse' is 'xterm', row/col bigger than 223 are not supported. |
123 " When 'ttymouse' is 'xterm', row/col bigger than 223 are not supported. | 123 if ttymouse_val !=# 'xterm' || row <= 223 |
124 continue | 124 call MouseLeftClick(row, col) |
125 endif | 125 let row -= 1 |
126 | 126 call MouseLeftDrag(row, col) |
127 call MouseLeftClick(row, col) | 127 call assert_equal(rowseparator - 1, winheight(0) + 1) |
128 | 128 let row += 1 |
129 let row -= 1 | 129 call MouseLeftDrag(row, col) |
130 call MouseLeftDrag(row, col) | 130 call assert_equal(rowseparator, winheight(0) + 1) |
131 call assert_equal(rowseparator - 1, winheight(0) + 1) | 131 call MouseLeftRelease(row, col) |
132 let row += 1 | 132 call assert_equal(rowseparator, winheight(0) + 1) |
133 call MouseLeftDrag(row, col) | 133 endif |
134 call assert_equal(rowseparator, winheight(0) + 1) | |
135 call MouseLeftRelease(row, col) | |
136 call assert_equal(rowseparator, winheight(0) + 1) | |
137 | |
138 bwipe! | 134 bwipe! |
139 | 135 |
140 " Split vertically and test dragging the vertical window separator. | 136 " Split vertically and test dragging the vertical window separator. |
141 vsplit | 137 vsplit |
142 let colseparator = winwidth(0) + 1 | 138 let colseparator = winwidth(0) + 1 |
143 | |
144 let row = 1 | 139 let row = 1 |
145 let col = colseparator | 140 let col = colseparator |
146 call MouseLeftClick(row, col) | 141 |
147 let col -= 1 | 142 " When 'ttymouse' is 'xterm', row/col bigger than 223 are not supported. |
148 call MouseLeftDrag(row, col) | 143 if ttymouse_val !=# 'xterm' || col <= 223 |
149 call assert_equal(colseparator - 1, winwidth(0) + 1) | 144 call MouseLeftClick(row, col) |
150 let col += 1 | 145 let col -= 1 |
151 call MouseLeftDrag(row, col) | 146 call MouseLeftDrag(row, col) |
152 call assert_equal(colseparator, winwidth(0) + 1) | 147 call assert_equal(colseparator - 1, winwidth(0) + 1) |
153 call MouseLeftRelease(row, col) | 148 let col += 1 |
154 call assert_equal(colseparator, winwidth(0) + 1) | 149 call MouseLeftDrag(row, col) |
155 | 150 call assert_equal(colseparator, winwidth(0) + 1) |
151 call MouseLeftRelease(row, col) | |
152 call assert_equal(colseparator, winwidth(0) + 1) | |
153 endif | |
156 bwipe! | 154 bwipe! |
157 endfor | 155 endfor |
158 | 156 |
159 let &mouse = save_mouse | 157 let &mouse = save_mouse |
160 let &term = save_term | 158 let &term = save_term |
219 \ 'Tab page 2', | 217 \ 'Tab page 2', |
220 \ '> Xbar'], a) | 218 \ '> Xbar'], a) |
221 | 219 |
222 " Test clicking on tab names in the tabline at the top. | 220 " Test clicking on tab names in the tabline at the top. |
223 let col = 2 | 221 let col = 2 |
224 redraw! | 222 redraw |
225 call MouseLeftClick(row, col) | 223 call MouseLeftClick(row, col) |
226 call MouseLeftRelease(row, col) | 224 call MouseLeftRelease(row, col) |
227 let a = split(execute(':tabs'), "\n") | 225 let a = split(execute(':tabs'), "\n") |
228 call assert_equal(['Tab page 1', | 226 call assert_equal(['Tab page 1', |
229 \ '> Xfoo', | 227 \ '> Xfoo', |
244 | 242 |
245 let &mouse = save_mouse | 243 let &mouse = save_mouse |
246 let &term = save_term | 244 let &term = save_term |
247 let &ttymouse = save_ttymouse | 245 let &ttymouse = save_ttymouse |
248 endfunc | 246 endfunc |
247 | |
248 func Test_xterm_mouse_click_X_to_close_tab() | |
249 let save_mouse = &mouse | |
250 let save_term = &term | |
251 let save_ttymouse = &ttymouse | |
252 set mouse=a term=xterm | |
253 let row = 1 | |
254 let col = &columns | |
255 | |
256 for ttymouse_val in ['xterm', 'sgr'] | |
257 if ttymouse_val ==# 'xterm' && col > 223 | |
258 " When 'ttymouse' is 'xterm', row/col bigger than 223 are not supported. | |
259 continue | |
260 endif | |
261 exe 'set ttymouse=' . ttymouse_val | |
262 e Xtab1 | |
263 tabnew Xtab2 | |
264 tabnew Xtab3 | |
265 tabn 2 | |
266 | |
267 let a = split(execute(':tabs'), "\n") | |
268 call assert_equal(['Tab page 1', | |
269 \ ' Xtab1', | |
270 \ 'Tab page 2', | |
271 \ '> Xtab2', | |
272 \ 'Tab page 3', | |
273 \ ' Xtab3'], a) | |
274 | |
275 " Click on "X" in tabline to close current tab i.e. Xtab2. | |
276 redraw | |
277 call MouseLeftClick(row, col) | |
278 call MouseLeftRelease(row, col) | |
279 let a = split(execute(':tabs'), "\n") | |
280 call assert_equal(['Tab page 1', | |
281 \ ' Xtab1', | |
282 \ 'Tab page 2', | |
283 \ '> Xtab3'], a) | |
284 | |
285 %bwipe! | |
286 endfor | |
287 | |
288 let &mouse = save_mouse | |
289 let &term = save_term | |
290 let &ttymouse = save_ttymouse | |
291 endfunc |