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