Patch 8.1.2337
Problem:    Double-click time sometimes miscomputed.
Solution:   Correct time computation. (Dominique Pelle, closes #5259)
Files:      src/mouse.c, src/testdir/runtest.vim


*** ../vim-8.1.2336/src/mouse.c 2019-11-18 23:31:44.964227445 +0100
--- src/mouse.c 2019-11-22 22:18:51.631551305 +0100
***************
*** 13,18 ****
--- 13,34 ----
  
  #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,2726 ****
                        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;
!                   }
                    orig_mouse_time = mouse_time;
                    if (mouse_code == orig_mouse_code
                            && timediff < p_mouset
--- 2729,2735 ----
                        timediff = p_mouset;
                    }
                    else
!                       timediff = time_diff_ms(&orig_mouse_time, &mouse_time);
                    orig_mouse_time = mouse_time;
                    if (mouse_code == orig_mouse_code
                            && timediff < p_mouset
*** ../vim-8.1.2336/src/testdir/runtest.vim     2019-11-21 18:26:58.070235538 
+0100
--- src/testdir/runtest.vim     2019-11-22 22:18:51.631551305 +0100
***************
*** 343,350 ****
        \ '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()',
--- 343,348 ----
*** ../vim-8.1.2336/src/version.c       2019-11-22 20:55:22.407621847 +0100
--- src/version.c       2019-11-22 22:21:00.235058970 +0100
***************
*** 739,740 ****
--- 739,742 ----
  {   /* Add new patch number below this line */
+ /**/
+     2337,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
109. You actually read -- and enjoy -- lists like this.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201911222122.xAMLMfpe026341%40masaka.moolenaar.net.

Raspunde prin e-mail lui