]> granicus.if.org Git - vim/commitdiff
patch 8.1.1786: double click in popup scrollbar starts selection v8.1.1786
authorBram Moolenaar <Bram@vim.org>
Thu, 1 Aug 2019 13:52:45 +0000 (15:52 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 1 Aug 2019 13:52:45 +0000 (15:52 +0200)
Problem:    Double click in popup scrollbar starts selection.
Solution:   Ignore the double click.

src/popupwin.c
src/proto/popupwin.pro
src/ui.c
src/version.c

index 856409798ad15315b57fe0be0cfff76bd2fde21a..ed01693d51a40bc9a4c144705ab456ab0969a47a 100644 (file)
@@ -304,6 +304,19 @@ popup_set_firstline(win_T *wp)
     }
 }
 
+/*
+ * Return TRUE if the position is in the popup window scrollbar.
+ */
+    int
+popup_is_in_scrollbar(win_T *wp, int row, int col)
+{
+    return wp->w_has_scrollbar
+       && row >= wp->w_popup_border[0]
+       && row < popup_height(wp) - wp->w_popup_border[2]
+       && col == popup_width(wp) - wp->w_popup_border[1] - 1;
+}
+
+
 /*
  * Handle a click in a popup window, if it is in the scrollbar.
  */
@@ -313,11 +326,7 @@ popup_handle_scrollbar_click(win_T *wp, int row, int col)
     int            height = popup_height(wp);
     int            old_topline = wp->w_topline;
 
-    if (wp->w_has_scrollbar == 0)
-       return;
-    if (row >= wp->w_popup_border[0]
-           && row < height - wp->w_popup_border[2]
-           && col == popup_width(wp) - wp->w_popup_border[1] - 1)
+    if (popup_is_in_scrollbar(wp, row, col))
     {
        if (row >= height / 2)
        {
index 0a5db0c480113b1e38ae4d91cc02885bba9ec2d3..145cbea25b3de21a3b7f1482d5a7ea2a41d5b3f3 100644 (file)
@@ -4,6 +4,7 @@ int popup_on_X_button(win_T *wp, int row, int col);
 void popup_start_drag(win_T *wp);
 void popup_drag(win_T *wp);
 void popup_set_firstline(win_T *wp);
+int popup_is_in_scrollbar(win_T *wp, int row, int col);
 void popup_handle_scrollbar_click(win_T *wp, int row, int col);
 int popup_height(win_T *wp);
 int popup_width(win_T *wp);
index 5d04e1b97f3e0d12587616f9229ea1f9cd244ec2..4e05859cbc565ace7c5cff996e6331e014c960a0 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -1058,6 +1058,17 @@ clip_compare_pos(
 clip_start_selection(int col, int row, int repeated_click)
 {
     Clipboard_T        *cb = &clip_star;
+#ifdef FEAT_TEXT_PROP
+    win_T      *wp;
+    int                row_cp = row;
+    int                col_cp = col;
+
+    wp = mouse_find_win(&row_cp, &col_cp, FIND_POPUP);
+    if (wp != NULL && WIN_IS_POPUP(wp)
+                                 && popup_is_in_scrollbar(wp, row_cp, col_cp))
+       // click or double click in scrollbar does not start a selection
+       return;
+#endif
 
     if (cb->state == SELECT_DONE)
        clip_clear_selection(cb);
@@ -1072,30 +1083,23 @@ clip_start_selection(int col, int row, int repeated_click)
     cb->origin_row  = (short_u)cb->start.lnum;
     cb->state      = SELECT_IN_PROGRESS;
 #ifdef FEAT_TEXT_PROP
+    if (wp != NULL && WIN_IS_POPUP(wp))
     {
-       win_T       *wp;
-       int         row_cp = row;
-       int         col_cp = col;
-
-       wp = mouse_find_win(&row_cp, &col_cp, FIND_POPUP);
-       if (wp != NULL && WIN_IS_POPUP(wp))
-       {
-           // Click in a popup window restricts selection to that window,
-           // excluding the border.
-           cb->min_col = wp->w_wincol + wp->w_popup_border[3];
-           cb->max_col = wp->w_wincol + popup_width(wp) - 1
-                                                      - wp->w_popup_border[1];
-           cb->min_row = wp->w_winrow + wp->w_popup_border[0];
-           cb->max_row = wp->w_winrow + popup_height(wp) - 1
-                                                      - wp->w_popup_border[2];
-       }
-       else
-       {
-           cb->min_col = 0;
-           cb->max_col = screen_Columns;
-           cb->min_row = 0;
-           cb->max_row = screen_Rows;
-       }
+       // Click in a popup window restricts selection to that window,
+       // excluding the border.
+       cb->min_col = wp->w_wincol + wp->w_popup_border[3];
+       cb->max_col = wp->w_wincol + popup_width(wp) - 1
+                                                  - wp->w_popup_border[1];
+       cb->min_row = wp->w_winrow + wp->w_popup_border[0];
+       cb->max_row = wp->w_winrow + popup_height(wp) - 1
+                                                  - wp->w_popup_border[2];
+    }
+    else
+    {
+       cb->min_col = 0;
+       cb->max_col = screen_Columns;
+       cb->min_row = 0;
+       cb->max_row = screen_Rows;
     }
 #endif
 
index 53ab0c90a8a0bc7e48843887ed8c9a6ef7d1d5b0..0e30df7cd386e6474e0da77293bbb55cdfabf06c 100644 (file)
@@ -773,6 +773,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1786,
 /**/
     1785,
 /**/