Mercurial > vim
changeset 18627:169c810d4e51 v8.1.2306
patch 8.1.2306: double and triple clicks are not tested
Commit: https://github.com/vim/vim/commit/f36a2c7e60d86b1a1733a8f51ed72da9c6f76eb8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 16 18:57:16 2019 +0100
patch 8.1.2306: double and triple clicks are not tested
Problem: Double and triple clicks are not tested.
Solution: Test mouse clicks to select text. (closes https://github.com/vim/vim/issues/5226)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 16 Nov 2019 19:00:05 +0100 |
parents | 44ddfa8731ae |
children | cab958d39c1c |
files | src/testdir/test_termcodes.vim src/version.c |
diffstat | 2 files changed, 90 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -674,8 +674,11 @@ func Test_term_mouse_drag_to_move_tab() \ 'Tab page 2', \ ' Xtab1'], a, msg) - " brief sleep to avoid causing a double-click - sleep 20m + " Click elsewhere so that click in next iteration is not + " interpreted as unwanted double-click. + call MouseLeftClick(row, 11) + call MouseLeftRelease(row, 11) + %bwipe! endfor @@ -693,24 +696,16 @@ func Test_term_mouse_double_click_to_cre call test_override('no_query_mouse', 1) " Set 'mousetime' to a small value, so that double-click works but we don't " have to wait long to avoid a triple-click. - set mouse=a term=xterm mousetime=100 + set mouse=a term=xterm mousetime=200 let row = 1 let col = 10 - let round = 0 for ttymouse_val in s:ttymouse_values + s:ttymouse_dec let msg = 'ttymouse=' .. ttymouse_val exe 'set ttymouse=' .. ttymouse_val e Xtab1 tabnew Xtab2 - if round > 0 - " We need to sleep, or else the first MouseLeftClick() will be - " interpreted as a spurious triple-click. - sleep 100m - endif - let round += 1 - let a = split(execute(':tabs'), "\n") call assert_equal(['Tab page 1', \ ' Xtab1', @@ -734,6 +729,11 @@ func Test_term_mouse_double_click_to_cre \ 'Tab page 3', \ ' Xtab2'], a, msg) + " Click elsewhere so that click in next iteration is not + " interpreted as unwanted double click. + call MouseLeftClick(row, col + 1) + call MouseLeftRelease(row, col + 1) + %bwipe! endfor @@ -744,6 +744,83 @@ func Test_term_mouse_double_click_to_cre set mousetime& endfunc +" Test double/triple/quadruple click in normal mode to visually select. +func Test_term_mouse_multiple_clicks_to_visually_select() + let save_mouse = &mouse + let save_term = &term + let save_ttymouse = &ttymouse + call test_override('no_query_mouse', 1) + set mouse=a term=xterm mousetime=200 + new + + for ttymouse_val in s:ttymouse_values + s:ttymouse_dec + let msg = 'ttymouse=' .. ttymouse_val + exe 'set ttymouse=' .. ttymouse_val + call setline(1, ['foo [foo bar] foo', 'foo']) + + " Double-click on word should visually select the word. + call MouseLeftClick(1, 2) + call assert_equal(0, getcharmod(), msg) + call MouseLeftRelease(1, 2) + call MouseLeftClick(1, 2) + call assert_equal(32, getcharmod(), msg) " double-click + call MouseLeftRelease(1, 2) + call assert_equal('v', mode(), msg) + norm! r1 + call assert_equal(['111 [foo bar] foo', 'foo'], getline(1, '$'), msg) + + " Double-click on opening square bracket should visually + " select the whole [foo bar]. + call MouseLeftClick(1, 5) + call assert_equal(0, getcharmod(), msg) + call MouseLeftRelease(1, 5) + call MouseLeftClick(1, 5) + call assert_equal(32, getcharmod(), msg) " double-click + call MouseLeftRelease(1, 5) + call assert_equal('v', mode(), msg) + norm! r2 + call assert_equal(['111 222222222 foo', 'foo'], getline(1, '$'), msg) + + " Triple-click should visually select the whole line. + call MouseLeftClick(1, 3) + call assert_equal(0, getcharmod(), msg) + call MouseLeftRelease(1, 3) + call MouseLeftClick(1, 3) + call assert_equal(32, getcharmod(), msg) " double-click + call MouseLeftRelease(1, 3) + call MouseLeftClick(1, 3) + call assert_equal(64, getcharmod(), msg) " triple-click + call MouseLeftRelease(1, 3) + call assert_equal('V', mode(), msg) + norm! r3 + call assert_equal(['33333333333333333', 'foo'], getline(1, '$'), msg) + + " Quadruple-click should start visual block select. + call MouseLeftClick(1, 2) + call assert_equal(0, getcharmod(), msg) + call MouseLeftRelease(1, 2) + call MouseLeftClick(1, 2) + call assert_equal(32, getcharmod(), msg) " double-click + call MouseLeftRelease(1, 2) + call MouseLeftClick(1, 2) + call assert_equal(64, getcharmod(), msg) " triple-click + call MouseLeftRelease(1, 2) + call MouseLeftClick(1, 2) + call assert_equal(96, getcharmod(), msg) " quadruple-click + call MouseLeftRelease(1, 2) + call assert_equal("\<c-v>", mode(), msg) + norm! r4 + call assert_equal(['34333333333333333', 'foo'], getline(1, '$'), msg) + endfor + + let &mouse = save_mouse + let &term = save_term + let &ttymouse = save_ttymouse + set mousetime& + call test_override('no_query_mouse', 0) + bwipe! +endfunc + func Test_xterm_mouse_click_in_fold_columns() new let save_mouse = &mouse