Patch 9.0.0825
Solution:   Clear dragwin instead of got_click. (closes #11483,
            closes #11482)
Files:      src/mouse.c, src/proto/mouse.pro, src/window.c,
            src/testdir/test_termcodes.vim


*** ../vim-9.0.0824/src/mouse.c 2022-10-31 13:04:59.497449003 +0000
--- src/mouse.c 2022-11-01 18:24:23.311578070 +0000
***************
*** 179,196 ****
  }
  #endif
  
- static int    mouse_got_click = FALSE;        // got a click some time back
- 
- /*
-  * Reset the flag that a mouse click was seen.  To be called when switching 
tab
-  * page.
-  */
-     void
- reset_mouse_got_click(void)
- {
-     mouse_got_click = FALSE;
- }
- 
  /*
   * Do the appropriate action for the current mouse click in the current mode.
   * Not used for Command-line mode.
--- 179,184 ----
***************
*** 236,241 ****
--- 224,230 ----
      int               fixindent)      // PUT_FIXINDENT if fixing indent 
necessary
  {
      static int        do_always = FALSE;      // ignore 'mouse' setting next 
time
+     static int        got_click = FALSE;      // got a click some time back
  
      int               which_button;   // MOUSE_LEFT, _MIDDLE or _RIGHT
      int               is_click = FALSE; // If FALSE it's a drag or release 
event
***************
*** 347,360 ****
  
      // Ignore drag and release events if we didn't get a click.
      if (is_click)
!       mouse_got_click = TRUE;
      else
      {
!       if (!mouse_got_click)                   // didn't get click, ignore
            return FALSE;
!       if (!is_drag)                   // release, reset mouse_got_click
        {
!           mouse_got_click = FALSE;
            if (in_tab_line)
            {
                in_tab_line = FALSE;
--- 336,349 ----
  
      // Ignore drag and release events if we didn't get a click.
      if (is_click)
!       got_click = TRUE;
      else
      {
!       if (!got_click)                 // didn't get click, ignore
            return FALSE;
!       if (!is_drag)                   // release, reset got_click
        {
!           got_click = FALSE;
            if (in_tab_line)
            {
                in_tab_line = FALSE;
***************
*** 371,377 ****
        if (count > 1)
            stuffnumReadbuff(count);
        stuffcharReadbuff(Ctrl_T);
!       mouse_got_click = FALSE;                // ignore drag&release now
        return FALSE;
      }
  
--- 360,366 ----
        if (count > 1)
            stuffnumReadbuff(count);
        stuffcharReadbuff(Ctrl_T);
!       got_click = FALSE;              // ignore drag&release now
        return FALSE;
      }
  
***************
*** 652,658 ****
            }
  # ifdef FEAT_MENU
            show_popupmenu();
!           mouse_got_click = FALSE;    // ignore release events
  # endif
            return (jump_flags & CURSOR_MOVED) != 0;
  #else
--- 641,647 ----
            }
  # ifdef FEAT_MENU
            show_popupmenu();
!           got_click = FALSE;  // ignore release events
  # endif
            return (jump_flags & CURSOR_MOVED) != 0;
  #else
***************
*** 709,715 ****
      // next mouse click.
      if (!is_drag && oap != NULL && oap->op_type != OP_NOP)
      {
!       mouse_got_click = FALSE;
        oap->motion_type = MCHAR;
      }
  
--- 698,704 ----
      // next mouse click.
      if (!is_drag && oap != NULL && oap->op_type != OP_NOP)
      {
!       got_click = FALSE;
        oap->motion_type = MCHAR;
      }
  
***************
*** 908,914 ****
            do_cmdline_cmd((char_u *)".cc");
        else                                    // location list window
            do_cmdline_cmd((char_u *)".ll");
!       mouse_got_click = FALSE;                // ignore drag&release now
      }
  #endif
  
--- 897,903 ----
            do_cmdline_cmd((char_u *)".cc");
        else                                    // location list window
            do_cmdline_cmd((char_u *)".ll");
!       got_click = FALSE;              // ignore drag&release now
      }
  #endif
  
***************
*** 920,926 ****
        if (State & MODE_INSERT)
            stuffcharReadbuff(Ctrl_O);
        stuffcharReadbuff(Ctrl_RSB);
!       mouse_got_click = FALSE;                // ignore drag&release now
      }
  
      // Shift-Mouse click searches for the next occurrence of the word under
--- 909,915 ----
        if (State & MODE_INSERT)
            stuffcharReadbuff(Ctrl_O);
        stuffcharReadbuff(Ctrl_RSB);
!       got_click = FALSE;              // ignore drag&release now
      }
  
      // Shift-Mouse click searches for the next occurrence of the word under
***************
*** 1513,1518 ****
--- 1502,1518 ----
      return (p_mousem[0] == 'p');
  }
  
+ static win_T *dragwin = NULL; // window being dragged
+ 
+ /*
+  * Reset the window being dragged.  To be called when switching tab page.
+  */
+     void
+ reset_dragwin(void)
+ {
+     dragwin = NULL;
+ }
+ 
  /*
   * Move the cursor to the specified row and column on the screen.
   * Change current window if necessary.        Returns an integer with the
***************
*** 1556,1562 ****
  #endif
      static int        prev_row = -1;
      static int        prev_col = -1;
-     static win_T *dragwin = NULL;     // window being dragged
      static int        did_drag = FALSE;       // drag was noticed
  
      win_T     *wp, *old_curwin;
--- 1556,1561 ----
*** ../vim-9.0.0824/src/proto/mouse.pro 2022-10-31 13:04:59.497449003 +0000
--- src/proto/mouse.pro 2022-11-01 18:24:23.311578070 +0000
***************
*** 1,7 ****
  /* mouse.c */
  void mouse_set_vert_scroll_step(long step);
  void mouse_set_hor_scroll_step(long step);
- void reset_mouse_got_click(void);
  int do_mouse(oparg_T *oap, int c, int dir, long count, int fixindent);
  void ins_mouse(int c);
  void ins_mousescroll(int dir);
--- 1,6 ----
***************
*** 13,18 ****
--- 12,18 ----
  void setmouse(void);
  int mouse_has(int c);
  int mouse_model_popup(void);
+ void reset_dragwin(void);
  int jump_to_mouse(int flags, int *inclusive, int which_button);
  void nv_mousescroll(cmdarg_T *cap);
  void nv_mouse(cmdarg_T *cap);
*** ../vim-9.0.0824/src/window.c        2022-10-31 23:06:52.004079731 +0000
--- src/window.c        2022-11-01 18:24:23.311578070 +0000
***************
*** 4269,4275 ****
            return FAIL;
      }
  
!     reset_mouse_got_click();
  #if defined(FEAT_GUI)
      // Remove the scrollbars.  They may be added back later.
      if (gui.in_use)
--- 4269,4275 ----
            return FAIL;
      }
  
!     reset_dragwin();
  #if defined(FEAT_GUI)
      // Remove the scrollbars.  They may be added back later.
      if (gui.in_use)
***************
*** 4338,4344 ****
  
      // If there was a click in a window, it won't be usable for a following
      // drag.
!     reset_mouse_got_click();
  
      // The tabpage line may have appeared or disappeared, may need to resize
      // the frames for that.  When the Vim window was resized need to update
--- 4338,4344 ----
  
      // If there was a click in a window, it won't be usable for a following
      // drag.
!     reset_dragwin();
  
      // The tabpage line may have appeared or disappeared, may need to resize
      // the frames for that.  When the Vim window was resized need to update
*** ../vim-9.0.0824/src/testdir/test_termcodes.vim      2022-10-31 
23:06:52.004079731 +0000
--- src/testdir/test_termcodes.vim      2022-11-01 18:24:23.311578070 +0000
***************
*** 562,572 ****
        call MouseLeftClick(row, col)
        let row -= 1
        call MouseLeftDrag(row, col)
!       " FIXME: for unknown reason this test fails, related to calling
!       " reset_mouse_got_click() earlier.
!       if ttymouse_val !=# 'xterm2'
!         call assert_equal(rowseparator - 1, winheight(0) + 1, msg)
!       endif
        let row += 1
        call MouseLeftDrag(row, col)
        call assert_equal(rowseparator, winheight(0) + 1, msg)
--- 562,568 ----
        call MouseLeftClick(row, col)
        let row -= 1
        call MouseLeftDrag(row, col)
!       call assert_equal(rowseparator - 1, winheight(0) + 1, msg)
        let row += 1
        call MouseLeftDrag(row, col)
        call assert_equal(rowseparator, winheight(0) + 1, msg)
***************
*** 779,784 ****
--- 775,802 ----
          \              'Tab page 2',
          \              '    Xtab1'], a, msg)
  
+     " Switch to tab1
+     tabnext
+     let a = split(execute(':tabs'), "\n")
+     call assert_equal(['Tab page 1',
+         \              '    Xtab2',
+         \              'Tab page 2',
+         \              '>   Xtab1'], a, msg)
+ 
+     " Click in tab2 and drag it to tab1.
+     " This time it is non-current tab.
+     call MouseLeftClick(row, 6)
+     call assert_equal(0, getcharmod(), msg)
+     for col in [7, 8, 9, 10]
+       call MouseLeftDrag(row, col)
+     endfor
+     call MouseLeftRelease(row, col)
+     let a = split(execute(':tabs'), "\n")
+     call assert_equal(['Tab page 1',
+         \              '    Xtab1',
+         \              'Tab page 2',
+         \              '>   Xtab2'], a, msg)
+ 
      " Click elsewhere so that click in next iteration is not
      " interpreted as unwanted double-click.
      call MouseLeftClick(row, 11)
*** ../vim-9.0.0824/src/version.c       2022-11-01 11:44:12.690558580 +0000
--- src/version.c       2022-11-01 18:27:43.731714187 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     825,
  /**/

-- 
A)bort, R)etry, P)lease don't bother me again

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20221101183742.C26871C0739%40moolenaar.net.

Raspunde prin e-mail lui