Karsten Hopp 31ba1b
To: vim-dev@vim.org
Karsten Hopp 31ba1b
Subject: Patch 7.1.231
Karsten Hopp 31ba1b
Fcc: outbox
Karsten Hopp 31ba1b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 31ba1b
Mime-Version: 1.0
Karsten Hopp 31ba1b
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 31ba1b
Content-Transfer-Encoding: 8bit
Karsten Hopp 31ba1b
------------
Karsten Hopp 31ba1b
Karsten Hopp 31ba1b
Patch 7.1.231
Karsten Hopp 31ba1b
Problem:    When shifting lines the change is acted upon multiple times.
Karsten Hopp 31ba1b
Solution:   Don't have shift_line() call changed_bytes.
Karsten Hopp 31ba1b
Files:	    src/edit.c, src/ops.c, src/proto/edit.pro, src/proto/ops.pro
Karsten Hopp 31ba1b
Karsten Hopp 31ba1b
Karsten Hopp 31ba1b
*** ../vim-7.1.230/src/edit.c	Mon Jan 14 20:11:37 2008
Karsten Hopp 31ba1b
--- src/edit.c	Mon Jan 14 20:06:43 2008
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 1662,1672 ****
Karsten Hopp 31ba1b
   * if round is TRUE, round the indent to 'shiftwidth' (only with _INC and _Dec).
Karsten Hopp 31ba1b
   */
Karsten Hopp 31ba1b
      void
Karsten Hopp 31ba1b
! change_indent(type, amount, round, replaced)
Karsten Hopp 31ba1b
      int		type;
Karsten Hopp 31ba1b
      int		amount;
Karsten Hopp 31ba1b
      int		round;
Karsten Hopp 31ba1b
      int		replaced;	/* replaced character, put on replace stack */
Karsten Hopp 31ba1b
  {
Karsten Hopp 31ba1b
      int		vcol;
Karsten Hopp 31ba1b
      int		last_vcol;
Karsten Hopp 31ba1b
--- 1662,1673 ----
Karsten Hopp 31ba1b
   * if round is TRUE, round the indent to 'shiftwidth' (only with _INC and _Dec).
Karsten Hopp 31ba1b
   */
Karsten Hopp 31ba1b
      void
Karsten Hopp 31ba1b
! change_indent(type, amount, round, replaced, call_changed_bytes)
Karsten Hopp 31ba1b
      int		type;
Karsten Hopp 31ba1b
      int		amount;
Karsten Hopp 31ba1b
      int		round;
Karsten Hopp 31ba1b
      int		replaced;	/* replaced character, put on replace stack */
Karsten Hopp 31ba1b
+     int		call_changed_bytes;	/* call changed_bytes() */
Karsten Hopp 31ba1b
  {
Karsten Hopp 31ba1b
      int		vcol;
Karsten Hopp 31ba1b
      int		last_vcol;
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 1723,1729 ****
Karsten Hopp 31ba1b
       * Set the new indent.  The cursor will be put on the first non-blank.
Karsten Hopp 31ba1b
       */
Karsten Hopp 31ba1b
      if (type == INDENT_SET)
Karsten Hopp 31ba1b
! 	(void)set_indent(amount, SIN_CHANGED);
Karsten Hopp 31ba1b
      else
Karsten Hopp 31ba1b
      {
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
--- 1724,1730 ----
Karsten Hopp 31ba1b
       * Set the new indent.  The cursor will be put on the first non-blank.
Karsten Hopp 31ba1b
       */
Karsten Hopp 31ba1b
      if (type == INDENT_SET)
Karsten Hopp 31ba1b
! 	(void)set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);
Karsten Hopp 31ba1b
      else
Karsten Hopp 31ba1b
      {
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 1733,1739 ****
Karsten Hopp 31ba1b
  	if (State & VREPLACE_FLAG)
Karsten Hopp 31ba1b
  	    State = INSERT;
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
! 	shift_line(type == INDENT_DEC, round, 1);
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
  	State = save_State;
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
--- 1734,1740 ----
Karsten Hopp 31ba1b
  	if (State & VREPLACE_FLAG)
Karsten Hopp 31ba1b
  	    State = INSERT;
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
! 	shift_line(type == INDENT_DEC, round, 1, call_changed_bytes);
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
  	State = save_State;
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 5921,5927 ****
Karsten Hopp 31ba1b
  	    {
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
  		if (State & VREPLACE_FLAG)
Karsten Hopp 31ba1b
! 		    change_indent(INDENT_SET, second_indent, FALSE, NUL);
Karsten Hopp 31ba1b
  		else
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
  		    (void)set_indent(second_indent, SIN_CHANGED);
Karsten Hopp 31ba1b
--- 5922,5928 ----
Karsten Hopp 31ba1b
  	    {
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
  		if (State & VREPLACE_FLAG)
Karsten Hopp 31ba1b
! 		    change_indent(INDENT_SET, second_indent, FALSE, NUL, TRUE);
Karsten Hopp 31ba1b
  		else
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
  		    (void)set_indent(second_indent, SIN_CHANGED);
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 7227,7233 ****
Karsten Hopp 31ba1b
  fixthisline(get_the_indent)
Karsten Hopp 31ba1b
      int (*get_the_indent) __ARGS((void));
Karsten Hopp 31ba1b
  {
Karsten Hopp 31ba1b
!     change_indent(INDENT_SET, get_the_indent(), FALSE, 0);
Karsten Hopp 31ba1b
      if (linewhite(curwin->w_cursor.lnum))
Karsten Hopp 31ba1b
  	did_ai = TRUE;	    /* delete the indent if the line stays empty */
Karsten Hopp 31ba1b
  }
Karsten Hopp 31ba1b
--- 7228,7234 ----
Karsten Hopp 31ba1b
  fixthisline(get_the_indent)
Karsten Hopp 31ba1b
      int (*get_the_indent) __ARGS((void));
Karsten Hopp 31ba1b
  {
Karsten Hopp 31ba1b
!     change_indent(INDENT_SET, get_the_indent(), FALSE, 0, TRUE);
Karsten Hopp 31ba1b
      if (linewhite(curwin->w_cursor.lnum))
Karsten Hopp 31ba1b
  	did_ai = TRUE;	    /* delete the indent if the line stays empty */
Karsten Hopp 31ba1b
  }
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 8170,8179 ****
Karsten Hopp 31ba1b
  	    replace_pop_ins();
Karsten Hopp 31ba1b
  	if (lastc == '^')
Karsten Hopp 31ba1b
  	    old_indent = get_indent();	/* remember curr. indent */
Karsten Hopp 31ba1b
! 	change_indent(INDENT_SET, 0, TRUE, 0);
Karsten Hopp 31ba1b
      }
Karsten Hopp 31ba1b
      else
Karsten Hopp 31ba1b
! 	change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0);
Karsten Hopp 31ba1b
  
Karsten Hopp 31ba1b
      if (did_ai && *skipwhite(ml_get_curline()) != NUL)
Karsten Hopp 31ba1b
  	did_ai = FALSE;
Karsten Hopp 31ba1b
--- 8171,8180 ----
Karsten Hopp 31ba1b
  	    replace_pop_ins();
Karsten Hopp 31ba1b
  	if (lastc == '^')
Karsten Hopp 31ba1b
  	    old_indent = get_indent();	/* remember curr. indent */
Karsten Hopp 31ba1b
! 	change_indent(INDENT_SET, 0, TRUE, 0, TRUE);
Karsten Hopp 31ba1b
      }
Karsten Hopp 31ba1b
      else
Karsten Hopp 31ba1b
! 	change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, TRUE, 0, TRUE);
Karsten Hopp 31ba1b
  
Karsten Hopp 31ba1b
      if (did_ai && *skipwhite(ml_get_curline()) != NUL)
Karsten Hopp 31ba1b
  	did_ai = FALSE;
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 9633,9639 ****
Karsten Hopp 31ba1b
  	    curwin->w_cursor = old_pos;
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
  	    if (State & VREPLACE_FLAG)
Karsten Hopp 31ba1b
! 		change_indent(INDENT_SET, i, FALSE, NUL);
Karsten Hopp 31ba1b
  	    else
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
  		(void)set_indent(i, SIN_CHANGED);
Karsten Hopp 31ba1b
--- 9634,9640 ----
Karsten Hopp 31ba1b
  	    curwin->w_cursor = old_pos;
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
  	    if (State & VREPLACE_FLAG)
Karsten Hopp 31ba1b
! 		change_indent(INDENT_SET, i, FALSE, NUL, TRUE);
Karsten Hopp 31ba1b
  	    else
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
  		(void)set_indent(i, SIN_CHANGED);
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 9662,9668 ****
Karsten Hopp 31ba1b
  		curwin->w_cursor = old_pos;
Karsten Hopp 31ba1b
  	    }
Karsten Hopp 31ba1b
  	    if (temp)
Karsten Hopp 31ba1b
! 		shift_line(TRUE, FALSE, 1);
Karsten Hopp 31ba1b
  	}
Karsten Hopp 31ba1b
      }
Karsten Hopp 31ba1b
  
Karsten Hopp 31ba1b
--- 9663,9669 ----
Karsten Hopp 31ba1b
  		curwin->w_cursor = old_pos;
Karsten Hopp 31ba1b
  	    }
Karsten Hopp 31ba1b
  	    if (temp)
Karsten Hopp 31ba1b
! 		shift_line(TRUE, FALSE, 1, TRUE);
Karsten Hopp 31ba1b
  	}
Karsten Hopp 31ba1b
      }
Karsten Hopp 31ba1b
  
Karsten Hopp 31ba1b
*** ../vim-7.1.230/src/ops.c	Thu Jan  3 16:31:17 2008
Karsten Hopp 31ba1b
--- src/ops.c	Sun Jan 13 21:52:18 2008
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 258,264 ****
Karsten Hopp 31ba1b
  	    if (first_char != '#' || !preprocs_left())
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
  	{
Karsten Hopp 31ba1b
! 	    shift_line(oap->op_type == OP_LSHIFT, p_sr, amount);
Karsten Hopp 31ba1b
  	}
Karsten Hopp 31ba1b
  	++curwin->w_cursor.lnum;
Karsten Hopp 31ba1b
      }
Karsten Hopp 31ba1b
--- 258,264 ----
Karsten Hopp 31ba1b
  	    if (first_char != '#' || !preprocs_left())
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
  	{
Karsten Hopp 31ba1b
! 	    shift_line(oap->op_type == OP_LSHIFT, p_sr, amount, FALSE);
Karsten Hopp 31ba1b
  	}
Karsten Hopp 31ba1b
  	++curwin->w_cursor.lnum;
Karsten Hopp 31ba1b
      }
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 321,330 ****
Karsten Hopp 31ba1b
   * leaves cursor on first blank in the line
Karsten Hopp 31ba1b
   */
Karsten Hopp 31ba1b
      void
Karsten Hopp 31ba1b
! shift_line(left, round, amount)
Karsten Hopp 31ba1b
      int	left;
Karsten Hopp 31ba1b
      int	round;
Karsten Hopp 31ba1b
      int	amount;
Karsten Hopp 31ba1b
  {
Karsten Hopp 31ba1b
      int		count;
Karsten Hopp 31ba1b
      int		i, j;
Karsten Hopp 31ba1b
--- 321,331 ----
Karsten Hopp 31ba1b
   * leaves cursor on first blank in the line
Karsten Hopp 31ba1b
   */
Karsten Hopp 31ba1b
      void
Karsten Hopp 31ba1b
! shift_line(left, round, amount, call_changed_bytes)
Karsten Hopp 31ba1b
      int	left;
Karsten Hopp 31ba1b
      int	round;
Karsten Hopp 31ba1b
      int	amount;
Karsten Hopp 31ba1b
+     int call_changed_bytes;	/* call changed_bytes() */
Karsten Hopp 31ba1b
  {
Karsten Hopp 31ba1b
      int		count;
Karsten Hopp 31ba1b
      int		i, j;
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 363,372 ****
Karsten Hopp 31ba1b
      /* Set new indent */
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
      if (State & VREPLACE_FLAG)
Karsten Hopp 31ba1b
! 	change_indent(INDENT_SET, count, FALSE, NUL);
Karsten Hopp 31ba1b
      else
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
! 	(void)set_indent(count, SIN_CHANGED);
Karsten Hopp 31ba1b
  }
Karsten Hopp 31ba1b
  
Karsten Hopp 31ba1b
  #if defined(FEAT_VISUALEXTRA) || defined(PROTO)
Karsten Hopp 31ba1b
--- 364,373 ----
Karsten Hopp 31ba1b
      /* Set new indent */
Karsten Hopp 31ba1b
  #ifdef FEAT_VREPLACE
Karsten Hopp 31ba1b
      if (State & VREPLACE_FLAG)
Karsten Hopp 31ba1b
! 	change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes);
Karsten Hopp 31ba1b
      else
Karsten Hopp 31ba1b
  #endif
Karsten Hopp 31ba1b
! 	(void)set_indent(count, call_changed_bytes ? SIN_CHANGED : 0);
Karsten Hopp 31ba1b
  }
Karsten Hopp 31ba1b
  
Karsten Hopp 31ba1b
  #if defined(FEAT_VISUALEXTRA) || defined(PROTO)
Karsten Hopp 31ba1b
*** ../vim-7.1.230/src/proto/edit.pro	Wed Jan  2 17:48:24 2008
Karsten Hopp 31ba1b
--- src/proto/edit.pro	Sun Jan 13 21:52:27 2008
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 3,9 ****
Karsten Hopp 31ba1b
  void edit_putchar __ARGS((int c, int highlight));
Karsten Hopp 31ba1b
  void edit_unputchar __ARGS((void));
Karsten Hopp 31ba1b
  void display_dollar __ARGS((colnr_T col));
Karsten Hopp 31ba1b
! void change_indent __ARGS((int type, int amount, int round, int replaced));
Karsten Hopp 31ba1b
  void truncate_spaces __ARGS((char_u *line));
Karsten Hopp 31ba1b
  void backspace_until_column __ARGS((int col));
Karsten Hopp 31ba1b
  int vim_is_ctrl_x_key __ARGS((int c));
Karsten Hopp 31ba1b
--- 3,9 ----
Karsten Hopp 31ba1b
  void edit_putchar __ARGS((int c, int highlight));
Karsten Hopp 31ba1b
  void edit_unputchar __ARGS((void));
Karsten Hopp 31ba1b
  void display_dollar __ARGS((colnr_T col));
Karsten Hopp 31ba1b
! void change_indent __ARGS((int type, int amount, int round, int replaced, int call_changed_bytes));
Karsten Hopp 31ba1b
  void truncate_spaces __ARGS((char_u *line));
Karsten Hopp 31ba1b
  void backspace_until_column __ARGS((int col));
Karsten Hopp 31ba1b
  int vim_is_ctrl_x_key __ARGS((int c));
Karsten Hopp 31ba1b
*** ../vim-7.1.230/src/proto/ops.pro	Sun May  6 13:56:32 2007
Karsten Hopp 31ba1b
--- src/proto/ops.pro	Sun Jan 13 21:52:30 2008
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 4,10 ****
Karsten Hopp 31ba1b
  int get_op_char __ARGS((int optype));
Karsten Hopp 31ba1b
  int get_extra_op_char __ARGS((int optype));
Karsten Hopp 31ba1b
  void op_shift __ARGS((oparg_T *oap, int curs_top, int amount));
Karsten Hopp 31ba1b
! void shift_line __ARGS((int left, int round, int amount));
Karsten Hopp 31ba1b
  void op_reindent __ARGS((oparg_T *oap, int (*how)(void)));
Karsten Hopp 31ba1b
  int get_expr_register __ARGS((void));
Karsten Hopp 31ba1b
  void set_expr_line __ARGS((char_u *new_line));
Karsten Hopp 31ba1b
--- 4,10 ----
Karsten Hopp 31ba1b
  int get_op_char __ARGS((int optype));
Karsten Hopp 31ba1b
  int get_extra_op_char __ARGS((int optype));
Karsten Hopp 31ba1b
  void op_shift __ARGS((oparg_T *oap, int curs_top, int amount));
Karsten Hopp 31ba1b
! void shift_line __ARGS((int left, int round, int amount, int call_changed_bytes));
Karsten Hopp 31ba1b
  void op_reindent __ARGS((oparg_T *oap, int (*how)(void)));
Karsten Hopp 31ba1b
  int get_expr_register __ARGS((void));
Karsten Hopp 31ba1b
  void set_expr_line __ARGS((char_u *new_line));
Karsten Hopp 31ba1b
*** ../vim-7.1.230/src/version.c	Tue Jan 15 22:16:36 2008
Karsten Hopp 31ba1b
--- src/version.c	Wed Jan 16 19:58:25 2008
Karsten Hopp 31ba1b
***************
Karsten Hopp 31ba1b
*** 668,669 ****
Karsten Hopp 31ba1b
--- 668,671 ----
Karsten Hopp 31ba1b
  {   /* Add new patch number below this line */
Karsten Hopp 31ba1b
+ /**/
Karsten Hopp 31ba1b
+     231,
Karsten Hopp 31ba1b
  /**/
Karsten Hopp 31ba1b
Karsten Hopp 31ba1b
-- 
Karsten Hopp 31ba1b
Snoring is prohibited unless all bedroom windows are closed and securely
Karsten Hopp 31ba1b
locked.
Karsten Hopp 31ba1b
		[real standing law in Massachusetts, United States of America]
Karsten Hopp 31ba1b
Karsten Hopp 31ba1b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 31ba1b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 31ba1b
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 31ba1b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///