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