Karsten Hopp 2934c1
To: vim-dev@vim.org
Karsten Hopp 2934c1
Subject: Patch 7.1.175
Karsten Hopp 2934c1
Fcc: outbox
Karsten Hopp 2934c1
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 2934c1
Mime-Version: 1.0
Karsten Hopp 2934c1
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 2934c1
Content-Transfer-Encoding: 8bit
Karsten Hopp 2934c1
------------
Karsten Hopp 2934c1
Karsten Hopp 2934c1
Patch 7.1.175
Karsten Hopp 2934c1
Problem:    <BS> doesn't work with some combination of 'sts', 'linebreak' and
Karsten Hopp 2934c1
	    'backspace'. (Francois Ingelrest)
Karsten Hopp 2934c1
Solution:   When adding white space results in not moving back delete one
Karsten Hopp 2934c1
	    character.
Karsten Hopp 2934c1
Files:	    src/edit.c
Karsten Hopp 2934c1
Karsten Hopp 2934c1
Karsten Hopp 2934c1
*** ../vim-7.1.174/src/edit.c	Sat Nov 24 21:27:33 2007
Karsten Hopp 2934c1
--- src/edit.c	Fri Dec  7 21:32:48 2007
Karsten Hopp 2934c1
***************
Karsten Hopp 2934c1
*** 8189,8194 ****
Karsten Hopp 2934c1
--- 8189,8217 ----
Karsten Hopp 2934c1
      AppendCharToRedobuff(K_DEL);
Karsten Hopp 2934c1
  }
Karsten Hopp 2934c1
  
Karsten Hopp 2934c1
+ static void ins_bs_one __ARGS((colnr_T *vcolp));
Karsten Hopp 2934c1
+ 
Karsten Hopp 2934c1
+ /*
Karsten Hopp 2934c1
+  * Delete one character for ins_bs().
Karsten Hopp 2934c1
+  */
Karsten Hopp 2934c1
+     static void
Karsten Hopp 2934c1
+ ins_bs_one(vcolp)
Karsten Hopp 2934c1
+     colnr_T	*vcolp;
Karsten Hopp 2934c1
+ {
Karsten Hopp 2934c1
+     dec_cursor();
Karsten Hopp 2934c1
+     getvcol(curwin, &curwin->w_cursor, vcolp, NULL, NULL);
Karsten Hopp 2934c1
+     if (State & REPLACE_FLAG)
Karsten Hopp 2934c1
+     {
Karsten Hopp 2934c1
+ 	/* Don't delete characters before the insert point when in
Karsten Hopp 2934c1
+ 	 * Replace mode */
Karsten Hopp 2934c1
+ 	if (curwin->w_cursor.lnum != Insstart.lnum
Karsten Hopp 2934c1
+ 		|| curwin->w_cursor.col >= Insstart.col)
Karsten Hopp 2934c1
+ 	    replace_do_bs();
Karsten Hopp 2934c1
+     }
Karsten Hopp 2934c1
+     else
Karsten Hopp 2934c1
+ 	(void)del_char(FALSE);
Karsten Hopp 2934c1
+ }
Karsten Hopp 2934c1
+ 
Karsten Hopp 2934c1
  /*
Karsten Hopp 2934c1
   * Handle Backspace, delete-word and delete-line in Insert mode.
Karsten Hopp 2934c1
   * Return TRUE when backspace was actually used.
Karsten Hopp 2934c1
***************
Karsten Hopp 2934c1
*** 8418,8426 ****
Karsten Hopp 2934c1
  	    int		ts;
Karsten Hopp 2934c1
  	    colnr_T	vcol;
Karsten Hopp 2934c1
  	    colnr_T	want_vcol;
Karsten Hopp 2934c1
! #if 0
Karsten Hopp 2934c1
! 	    int		extra = 0;
Karsten Hopp 2934c1
! #endif
Karsten Hopp 2934c1
  
Karsten Hopp 2934c1
  	    *inserted_space_p = FALSE;
Karsten Hopp 2934c1
  	    if (p_sta && in_indent)
Karsten Hopp 2934c1
--- 8441,8447 ----
Karsten Hopp 2934c1
  	    int		ts;
Karsten Hopp 2934c1
  	    colnr_T	vcol;
Karsten Hopp 2934c1
  	    colnr_T	want_vcol;
Karsten Hopp 2934c1
! 	    colnr_T	start_vcol;
Karsten Hopp 2934c1
  
Karsten Hopp 2934c1
  	    *inserted_space_p = FALSE;
Karsten Hopp 2934c1
  	    if (p_sta && in_indent)
Karsten Hopp 2934c1
***************
Karsten Hopp 2934c1
*** 8431,8436 ****
Karsten Hopp 2934c1
--- 8452,8458 ----
Karsten Hopp 2934c1
  	     * 'showbreak' may get in the way, need to get the last column of
Karsten Hopp 2934c1
  	     * the previous character. */
Karsten Hopp 2934c1
  	    getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
Karsten Hopp 2934c1
+ 	    start_vcol = vcol;
Karsten Hopp 2934c1
  	    dec_cursor();
Karsten Hopp 2934c1
  	    getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol);
Karsten Hopp 2934c1
  	    inc_cursor();
Karsten Hopp 2934c1
***************
Karsten Hopp 2934c1
*** 8439,8468 ****
Karsten Hopp 2934c1
  	    /* delete characters until we are at or before want_vcol */
Karsten Hopp 2934c1
  	    while (vcol > want_vcol
Karsten Hopp 2934c1
  		    && (cc = *(ml_get_cursor() - 1), vim_iswhite(cc)))
Karsten Hopp 2934c1
! 	    {
Karsten Hopp 2934c1
! 		dec_cursor();
Karsten Hopp 2934c1
! 		getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
Karsten Hopp 2934c1
! 		if (State & REPLACE_FLAG)
Karsten Hopp 2934c1
! 		{
Karsten Hopp 2934c1
! 		    /* Don't delete characters before the insert point when in
Karsten Hopp 2934c1
! 		     * Replace mode */
Karsten Hopp 2934c1
! 		    if (curwin->w_cursor.lnum != Insstart.lnum
Karsten Hopp 2934c1
! 			    || curwin->w_cursor.col >= Insstart.col)
Karsten Hopp 2934c1
! 		    {
Karsten Hopp 2934c1
! #if 0	/* what was this for?  It causes problems when sw != ts. */
Karsten Hopp 2934c1
! 			if (State == REPLACE && (int)vcol < want_vcol)
Karsten Hopp 2934c1
! 			{
Karsten Hopp 2934c1
! 			    (void)del_char(FALSE);
Karsten Hopp 2934c1
! 			    extra = 2;	/* don't pop too much */
Karsten Hopp 2934c1
! 			}
Karsten Hopp 2934c1
! 			else
Karsten Hopp 2934c1
! #endif
Karsten Hopp 2934c1
! 			    replace_do_bs();
Karsten Hopp 2934c1
! 		    }
Karsten Hopp 2934c1
! 		}
Karsten Hopp 2934c1
! 		else
Karsten Hopp 2934c1
! 		    (void)del_char(FALSE);
Karsten Hopp 2934c1
! 	    }
Karsten Hopp 2934c1
  
Karsten Hopp 2934c1
  	    /* insert extra spaces until we are at want_vcol */
Karsten Hopp 2934c1
  	    while (vcol < want_vcol)
Karsten Hopp 2934c1
--- 8461,8467 ----
Karsten Hopp 2934c1
  	    /* delete characters until we are at or before want_vcol */
Karsten Hopp 2934c1
  	    while (vcol > want_vcol
Karsten Hopp 2934c1
  		    && (cc = *(ml_get_cursor() - 1), vim_iswhite(cc)))
Karsten Hopp 2934c1
! 		ins_bs_one(&vcol);
Karsten Hopp 2934c1
  
Karsten Hopp 2934c1
  	    /* insert extra spaces until we are at want_vcol */
Karsten Hopp 2934c1
  	    while (vcol < want_vcol)
Karsten Hopp 2934c1
***************
Karsten Hopp 2934c1
*** 8479,8500 ****
Karsten Hopp 2934c1
  #endif
Karsten Hopp 2934c1
  		{
Karsten Hopp 2934c1
  		    ins_str((char_u *)" ");
Karsten Hopp 2934c1
! 		    if ((State & REPLACE_FLAG) /* && extra <= 1 */)
Karsten Hopp 2934c1
! 		    {
Karsten Hopp 2934c1
! #if 0
Karsten Hopp 2934c1
! 			if (extra)
Karsten Hopp 2934c1
! 			    replace_push_off(NUL);
Karsten Hopp 2934c1
! 			else
Karsten Hopp 2934c1
! #endif
Karsten Hopp 2934c1
! 			    replace_push(NUL);
Karsten Hopp 2934c1
! 		    }
Karsten Hopp 2934c1
! #if 0
Karsten Hopp 2934c1
! 		    if (extra == 2)
Karsten Hopp 2934c1
! 			extra = 1;
Karsten Hopp 2934c1
! #endif
Karsten Hopp 2934c1
  		}
Karsten Hopp 2934c1
  		getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
Karsten Hopp 2934c1
  	    }
Karsten Hopp 2934c1
  	}
Karsten Hopp 2934c1
  
Karsten Hopp 2934c1
  	/*
Karsten Hopp 2934c1
--- 8478,8493 ----
Karsten Hopp 2934c1
  #endif
Karsten Hopp 2934c1
  		{
Karsten Hopp 2934c1
  		    ins_str((char_u *)" ");
Karsten Hopp 2934c1
! 		    if ((State & REPLACE_FLAG))
Karsten Hopp 2934c1
! 			replace_push(NUL);
Karsten Hopp 2934c1
  		}
Karsten Hopp 2934c1
  		getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
Karsten Hopp 2934c1
  	    }
Karsten Hopp 2934c1
+ 
Karsten Hopp 2934c1
+ 	    /* If we are now back where we started delete one character.  Can
Karsten Hopp 2934c1
+ 	     * happen when using 'sts' and 'linebreak'. */
Karsten Hopp 2934c1
+ 	    if (vcol >= start_vcol)
Karsten Hopp 2934c1
+ 		ins_bs_one(&vcol);
Karsten Hopp 2934c1
  	}
Karsten Hopp 2934c1
  
Karsten Hopp 2934c1
  	/*
Karsten Hopp 2934c1
*** ../vim-7.1.174/src/version.c	Sun Dec  9 19:37:37 2007
Karsten Hopp 2934c1
--- src/version.c	Sun Dec  9 20:24:11 2007
Karsten Hopp 2934c1
***************
Karsten Hopp 2934c1
*** 668,669 ****
Karsten Hopp 2934c1
--- 668,671 ----
Karsten Hopp 2934c1
  {   /* Add new patch number below this line */
Karsten Hopp 2934c1
+ /**/
Karsten Hopp 2934c1
+     175,
Karsten Hopp 2934c1
  /**/
Karsten Hopp 2934c1
Karsten Hopp 2934c1
-- 
Karsten Hopp 2934c1
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 2934c1
215. Your mouse-clicking forearm rivals Popeye's.
Karsten Hopp 2934c1
Karsten Hopp 2934c1
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 2934c1
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 2934c1
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 2934c1
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///