diff options
-rw-r--r-- | src/mouse.c | 25 | ||||
-rw-r--r-- | src/testdir/runtest.vim | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 19 insertions, 10 deletions
diff --git a/src/mouse.c b/src/mouse.c index c141800689..9d0e39409d 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -13,6 +13,22 @@ #include "vim.h" +#ifdef CHECK_DOUBLE_CLICK +/* + * Return the duration from t1 to t2 in milliseconds. + */ + static long +time_diff_ms(struct timeval *t1, struct timeval *t2) +{ + // This handles wrapping of tv_usec correctly without any special case. + // Example of 2 pairs (tv_sec, tv_usec) with a duration of 5 ms: + // t1 = (1, 998000) t2 = (2, 3000) gives: + // (2 - 1) * 1000 + (3000 - 998000) / 1000 -> 5 ms. + return (t2->tv_sec - t1->tv_sec) * 1000 + + (t2->tv_usec - t1->tv_usec) / 1000; +} +#endif + /* * Get class of a character for selection: same class means same word. * 0: blank @@ -2713,14 +2729,7 @@ check_termcode_mouse( timediff = p_mouset; } else - { - timediff = (mouse_time.tv_usec - - orig_mouse_time.tv_usec) / 1000; - if (timediff < 0) - --orig_mouse_time.tv_sec; - timediff += (mouse_time.tv_sec - - orig_mouse_time.tv_sec) * 1000; - } + timediff = time_diff_ms(&orig_mouse_time, &mouse_time); orig_mouse_time = mouse_time; if (mouse_code == orig_mouse_code && timediff < p_mouset diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim index 2b416b910a..c05bd25fe8 100644 --- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -343,8 +343,6 @@ let s:flaky_tests = [ \ 'Test_reltime()', \ 'Test_server_crash()', \ 'Test_state()', - \ 'Test_term_mouse_double_click_to_create_tab()', - \ 'Test_term_mouse_multiple_clicks_to_visually_select()', \ 'Test_terminal_ansicolors_default()', \ 'Test_terminal_ansicolors_func()', \ 'Test_terminal_ansicolors_global()', diff --git a/src/version.c b/src/version.c index 137db0ec2e..996c3c5762 100644 --- a/src/version.c +++ b/src/version.c @@ -738,6 +738,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2337, +/**/ 2336, /**/ 2335, |