Subject: patch 5.4.31 (was: bug? after press return prompt in 5.4)
From: Bram Moolenaar <[email-masked]>
To: [email-masked]
Cc: [email-masked]

------------

Jeff Walker wrote:

> Okay, I have found what does it.  It took me a while, because I stopped
> being able to reproduce it.  That was frustrating.  Then I realized, it
> only happens when I have the screen split with :sp AND :set mousefocus.  I
> think it actually happens with I move the mouse across the split boundary.
> 
> Here is the basic test case:
> 
> $gvim -u NONE
> 
> <starts gvim>
> 
> :set mousefocus
> :sp
> 
> <has two windows, nothing in them>
> 
> :set
> 
> <makes the visible window scroll up, printing the options that differ from
> the default, giving the press return prompt>
> 
> now move the mouse up and down past the :sp boundary.  You should see it.

Yes, now I understand what happens.  Even though the screen has scrolled, the
mousefocus code is still active and reacts to the mouse moving into another
window.  Even though that window isn't where it used to be.

I noticed a few other flaws in 'mousefocus' and fixed these too.  A pending
command is not aborted, since the result would be quite unpredictible when
another window gets focus.  Visual mode isn't stopped, since you could
accidentally move the mouse outside of the window while extending the area.

Patch 5.4.31
Problem:    GUI: When 'mousefocus' is set, moving the mouse over where a
	    window boundary was, causes a hit-return prompt to be finished.
	    (Jeff Walker)
Solution:   Don't use 'mousefocus' at the hit-return prompt.  Also ignore it
	    for the more prompt and a few other situations.  When an operator
	    is pending, abort it first.
Files:	    src/gui.c

*** ../vim-5.4.30/src/gui.c	Tue Aug 10 16:10:31 1999
--- src/gui.c	Tue Aug 17 10:21:22 1999
***************
*** 2873,2880 ****
  
  /*
   * Called when the mouse moved (but not when dragging).
-  * Ignore this while in command-line mode, or while changing the window layout
-  * (causes a mouse-move event in Win32 GUI).
   */
      void
  gui_mouse_moved(y)
--- 2873,2878 ----
***************
*** 2884,2894 ****
      char_u	st[6];
      int		x;
  
!     /* Don't put events in the input queue now. */
!     if (hold_gui_events)
! 	return;
! 
!     if (p_mousef && State != CMDLINE && !need_mouse_correct && gui.in_focus)
      {
  	x = gui_mch_get_mouse_x();
  	/* Don't move the mouse when it's left or right of the Vim window */
--- 2882,2895 ----
      char_u	st[6];
      int		x;
  
!     /* Only handle this when 'mousefocus' set and ... */
!     if (p_mousef
! 	    && !hold_gui_events		/* not holding events */
! 	    && (State & (NORMAL|INSERT))/* Normal/Visual/Insert mode */
! 	    && State != HITRETURN	/* but not hit-return prompt */
! 	    && msg_scrolled == 0	/* no scrolled message */
! 	    && !need_mouse_correct	/* not moving the pointer */
! 	    && gui.in_focus)		/* gvim in focus */
      {
  	x = gui_mch_get_mouse_x();
  	/* Don't move the mouse when it's left or right of the Vim window */
***************
*** 2904,2909 ****
--- 2905,2916 ----
  	 * Trick: Use a column of -1, so that check_termcode will generate a
  	 * K_LEFTMOUSE_NM key code.
  	 */
+ 	if (finish_op)
+ 	{
+ 	    /* abort the current operator first */
+ 	    st[0] = ESC;
+ 	    add_to_input_buf(st, 1);
+ 	}
  	st[0] = CSI;
  	st[1] = KS_MOUSE;
  	st[2] = K_FILLER;
*** ../vim-5.4.30/src/version.h	Tue Aug 17 10:24:26 1999
--- src/version.h	Tue Aug 17 09:56:27 1999
***************
*** 19,26 ****
  #define VIM_VERSION_MINOR_STR		"4"
  #define VIM_VERSION_BUILD		 57
  #define VIM_VERSION_BUILD_STR		"57"
! #define VIM_VERSION_PATCHLEVEL		 30
! #define VIM_VERSION_PATCHLEVEL_STR	"30"
  
  /*
   * VIM_VERSION_NODOT is used for the runtime directory name.
--- 19,26 ----
  #define VIM_VERSION_MINOR_STR		"4"
  #define VIM_VERSION_BUILD		 57
  #define VIM_VERSION_BUILD_STR		"57"
! #define VIM_VERSION_PATCHLEVEL		 31
! #define VIM_VERSION_PATCHLEVEL_STR	"31"
  
  /*
   * VIM_VERSION_NODOT is used for the runtime directory name.
***************
*** 30,35 ****
   */
  #define VIM_VERSION_NODOT	"vim54"
  #define VIM_VERSION_SHORT	"5.4"
! #define VIM_VERSION_MEDIUM	"5.4.30"
! #define VIM_VERSION_LONG	"VIM - Vi IMproved 5.4.30 (1999 Aug 16)"
! #define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 5.4.30 (1999 Aug 16, compiled "
--- 30,35 ----
   */
  #define VIM_VERSION_NODOT	"vim54"
  #define VIM_VERSION_SHORT	"5.4"
! #define VIM_VERSION_MEDIUM	"5.4.31"
! #define VIM_VERSION_LONG	"VIM - Vi IMproved 5.4.31 (1999 Aug 17)"
! #define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 5.4.31 (1999 Aug 17, compiled "

--
hundred-and-one symptoms of being an internet addict:
107. When using your phone you forget that you don't have to use your
     keyboard.

--/-/---- Bram Moolenaar ---- [email-masked] ---- [email-masked] ---\-\--
  \ \    www.vim.org/iccf      www.moolenaar.net       www.vim.org    / /