mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.2337: double-click time sometimes miscomputed
Problem: Double-click time sometimes miscomputed. Solution: Correct time computation. (Dominique Pelle, closes #5259)
This commit is contained in:
parent
4ebe0e62d0
commit
85c3502ef5
25
src/mouse.c
25
src/mouse.c
@ -13,6 +13,22 @@
|
|||||||
|
|
||||||
#include "vim.h"
|
#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.
|
* Get class of a character for selection: same class means same word.
|
||||||
* 0: blank
|
* 0: blank
|
||||||
@ -2713,14 +2729,7 @@ check_termcode_mouse(
|
|||||||
timediff = p_mouset;
|
timediff = p_mouset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
timediff = time_diff_ms(&orig_mouse_time, &mouse_time);
|
||||||
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;
|
|
||||||
}
|
|
||||||
orig_mouse_time = mouse_time;
|
orig_mouse_time = mouse_time;
|
||||||
if (mouse_code == orig_mouse_code
|
if (mouse_code == orig_mouse_code
|
||||||
&& timediff < p_mouset
|
&& timediff < p_mouset
|
||||||
|
@ -343,8 +343,6 @@ let s:flaky_tests = [
|
|||||||
\ 'Test_reltime()',
|
\ 'Test_reltime()',
|
||||||
\ 'Test_server_crash()',
|
\ 'Test_server_crash()',
|
||||||
\ 'Test_state()',
|
\ '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_default()',
|
||||||
\ 'Test_terminal_ansicolors_func()',
|
\ 'Test_terminal_ansicolors_func()',
|
||||||
\ 'Test_terminal_ansicolors_global()',
|
\ 'Test_terminal_ansicolors_global()',
|
||||||
|
@ -737,6 +737,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2337,
|
||||||
/**/
|
/**/
|
||||||
2336,
|
2336,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user