Karsten Hopp 361ac5
To: vim_dev@googlegroups.com
Karsten Hopp 361ac5
Subject: Patch 7.3.333
Karsten Hopp 361ac5
Fcc: outbox
Karsten Hopp 361ac5
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 361ac5
Mime-Version: 1.0
Karsten Hopp 361ac5
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 361ac5
Content-Transfer-Encoding: 8bit
Karsten Hopp 361ac5
------------
Karsten Hopp 361ac5
Karsten Hopp 361ac5
Patch 7.3.333
Karsten Hopp 361ac5
Problem:    Using "." to repeat a Visual delete counts the size in bytes, not
Karsten Hopp 361ac5
	    characters.  (Connor Lane Smith)
Karsten Hopp 361ac5
Solution:   Store the virtual column numbers instead of byte positions.
Karsten Hopp 361ac5
Files:	    src/normal.c
Karsten Hopp 361ac5
Karsten Hopp 361ac5
Karsten Hopp 361ac5
*** ../vim-7.3.332/src/normal.c	2011-07-15 17:51:30.000000000 +0200
Karsten Hopp 361ac5
--- src/normal.c	2011-10-04 19:47:14.000000000 +0200
Karsten Hopp 361ac5
***************
Karsten Hopp 361ac5
*** 20,26 ****
Karsten Hopp 361ac5
   */
Karsten Hopp 361ac5
  static int	resel_VIsual_mode = NUL;	/* 'v', 'V', or Ctrl-V */
Karsten Hopp 361ac5
  static linenr_T	resel_VIsual_line_count;	/* number of lines */
Karsten Hopp 361ac5
! static colnr_T	resel_VIsual_col;		/* nr of cols or end col */
Karsten Hopp 361ac5
  
Karsten Hopp 361ac5
  static int	restart_VIsual_select = 0;
Karsten Hopp 361ac5
  #endif
Karsten Hopp 361ac5
--- 20,26 ----
Karsten Hopp 361ac5
   */
Karsten Hopp 361ac5
  static int	resel_VIsual_mode = NUL;	/* 'v', 'V', or Ctrl-V */
Karsten Hopp 361ac5
  static linenr_T	resel_VIsual_line_count;	/* number of lines */
Karsten Hopp 361ac5
! static colnr_T	resel_VIsual_vcol;		/* nr of cols or end col */
Karsten Hopp 361ac5
  
Karsten Hopp 361ac5
  static int	restart_VIsual_select = 0;
Karsten Hopp 361ac5
  #endif
Karsten Hopp 361ac5
***************
Karsten Hopp 361ac5
*** 1436,1442 ****
Karsten Hopp 361ac5
      /* The visual area is remembered for redo */
Karsten Hopp 361ac5
      static int	    redo_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */
Karsten Hopp 361ac5
      static linenr_T redo_VIsual_line_count; /* number of lines */
Karsten Hopp 361ac5
!     static colnr_T  redo_VIsual_col;	    /* number of cols or end column */
Karsten Hopp 361ac5
      static long	    redo_VIsual_count;	    /* count for Visual operator */
Karsten Hopp 361ac5
  # ifdef FEAT_VIRTUALEDIT
Karsten Hopp 361ac5
      int		    include_line_break = FALSE;
Karsten Hopp 361ac5
--- 1436,1442 ----
Karsten Hopp 361ac5
      /* The visual area is remembered for redo */
Karsten Hopp 361ac5
      static int	    redo_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */
Karsten Hopp 361ac5
      static linenr_T redo_VIsual_line_count; /* number of lines */
Karsten Hopp 361ac5
!     static colnr_T  redo_VIsual_vcol;	    /* number of cols or end column */
Karsten Hopp 361ac5
      static long	    redo_VIsual_count;	    /* count for Visual operator */
Karsten Hopp 361ac5
  # ifdef FEAT_VIRTUALEDIT
Karsten Hopp 361ac5
      int		    include_line_break = FALSE;
Karsten Hopp 361ac5
***************
Karsten Hopp 361ac5
*** 1549,1570 ****
Karsten Hopp 361ac5
  #ifdef FEAT_VISUAL
Karsten Hopp 361ac5
  	if (redo_VIsual_busy)
Karsten Hopp 361ac5
  	{
Karsten Hopp 361ac5
  	    oap->start = curwin->w_cursor;
Karsten Hopp 361ac5
  	    curwin->w_cursor.lnum += redo_VIsual_line_count - 1;
Karsten Hopp 361ac5
  	    if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
Karsten Hopp 361ac5
  		curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
Karsten Hopp 361ac5
  	    VIsual_mode = redo_VIsual_mode;
Karsten Hopp 361ac5
! 	    if (VIsual_mode == 'v')
Karsten Hopp 361ac5
  	    {
Karsten Hopp 361ac5
! 		if (redo_VIsual_line_count <= 1)
Karsten Hopp 361ac5
! 		    curwin->w_cursor.col += redo_VIsual_col - 1;
Karsten Hopp 361ac5
  		else
Karsten Hopp 361ac5
! 		    curwin->w_cursor.col = redo_VIsual_col;
Karsten Hopp 361ac5
! 	    }
Karsten Hopp 361ac5
! 	    if (redo_VIsual_col == MAXCOL)
Karsten Hopp 361ac5
! 	    {
Karsten Hopp 361ac5
! 		curwin->w_curswant = MAXCOL;
Karsten Hopp 361ac5
! 		coladvance((colnr_T)MAXCOL);
Karsten Hopp 361ac5
  	    }
Karsten Hopp 361ac5
  	    cap->count0 = redo_VIsual_count;
Karsten Hopp 361ac5
  	    if (redo_VIsual_count != 0)
Karsten Hopp 361ac5
--- 1549,1579 ----
Karsten Hopp 361ac5
  #ifdef FEAT_VISUAL
Karsten Hopp 361ac5
  	if (redo_VIsual_busy)
Karsten Hopp 361ac5
  	{
Karsten Hopp 361ac5
+ 	    /* Redo of an operation on a Visual area. Use the same size from
Karsten Hopp 361ac5
+ 	     * redo_VIsual_line_count and redo_VIsual_vcol. */
Karsten Hopp 361ac5
  	    oap->start = curwin->w_cursor;
Karsten Hopp 361ac5
  	    curwin->w_cursor.lnum += redo_VIsual_line_count - 1;
Karsten Hopp 361ac5
  	    if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
Karsten Hopp 361ac5
  		curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
Karsten Hopp 361ac5
  	    VIsual_mode = redo_VIsual_mode;
Karsten Hopp 361ac5
! 	    if (redo_VIsual_vcol == MAXCOL || VIsual_mode == 'v')
Karsten Hopp 361ac5
  	    {
Karsten Hopp 361ac5
! 		if (VIsual_mode == 'v')
Karsten Hopp 361ac5
! 		{
Karsten Hopp 361ac5
! 		    if (redo_VIsual_line_count <= 1)
Karsten Hopp 361ac5
! 		    {
Karsten Hopp 361ac5
! 			validate_virtcol();
Karsten Hopp 361ac5
! 			curwin->w_curswant =
Karsten Hopp 361ac5
! 				     curwin->w_virtcol + redo_VIsual_vcol - 1;
Karsten Hopp 361ac5
! 		    }
Karsten Hopp 361ac5
! 		    else
Karsten Hopp 361ac5
! 			curwin->w_curswant = redo_VIsual_vcol;
Karsten Hopp 361ac5
! 		}
Karsten Hopp 361ac5
  		else
Karsten Hopp 361ac5
! 		{
Karsten Hopp 361ac5
! 		    curwin->w_curswant = MAXCOL;
Karsten Hopp 361ac5
! 		}
Karsten Hopp 361ac5
! 		coladvance(curwin->w_curswant);
Karsten Hopp 361ac5
  	    }
Karsten Hopp 361ac5
  	    cap->count0 = redo_VIsual_count;
Karsten Hopp 361ac5
  	    if (redo_VIsual_count != 0)
Karsten Hopp 361ac5
***************
Karsten Hopp 361ac5
*** 1710,1716 ****
Karsten Hopp 361ac5
  		    }
Karsten Hopp 361ac5
  		}
Karsten Hopp 361ac5
  		else if (redo_VIsual_busy)
Karsten Hopp 361ac5
! 		    oap->end_vcol = oap->start_vcol + redo_VIsual_col - 1;
Karsten Hopp 361ac5
  		/*
Karsten Hopp 361ac5
  		 * Correct oap->end.col and oap->start.col to be the
Karsten Hopp 361ac5
  		 * upper-left and lower-right corner of the block area.
Karsten Hopp 361ac5
--- 1719,1725 ----
Karsten Hopp 361ac5
  		    }
Karsten Hopp 361ac5
  		}
Karsten Hopp 361ac5
  		else if (redo_VIsual_busy)
Karsten Hopp 361ac5
! 		    oap->end_vcol = oap->start_vcol + redo_VIsual_vcol - 1;
Karsten Hopp 361ac5
  		/*
Karsten Hopp 361ac5
  		 * Correct oap->end.col and oap->start.col to be the
Karsten Hopp 361ac5
  		 * upper-left and lower-right corner of the block area.
Karsten Hopp 361ac5
***************
Karsten Hopp 361ac5
*** 1735,1747 ****
Karsten Hopp 361ac5
  		 */
Karsten Hopp 361ac5
  		resel_VIsual_mode = VIsual_mode;
Karsten Hopp 361ac5
  		if (curwin->w_curswant == MAXCOL)
Karsten Hopp 361ac5
! 		    resel_VIsual_col = MAXCOL;
Karsten Hopp 361ac5
! 		else if (VIsual_mode == Ctrl_V)
Karsten Hopp 361ac5
! 		    resel_VIsual_col = oap->end_vcol - oap->start_vcol + 1;
Karsten Hopp 361ac5
! 		else if (oap->line_count > 1)
Karsten Hopp 361ac5
! 		    resel_VIsual_col = oap->end.col;
Karsten Hopp 361ac5
  		else
Karsten Hopp 361ac5
! 		    resel_VIsual_col = oap->end.col - oap->start.col + 1;
Karsten Hopp 361ac5
  		resel_VIsual_line_count = oap->line_count;
Karsten Hopp 361ac5
  	    }
Karsten Hopp 361ac5
  
Karsten Hopp 361ac5
--- 1744,1765 ----
Karsten Hopp 361ac5
  		 */
Karsten Hopp 361ac5
  		resel_VIsual_mode = VIsual_mode;
Karsten Hopp 361ac5
  		if (curwin->w_curswant == MAXCOL)
Karsten Hopp 361ac5
! 		    resel_VIsual_vcol = MAXCOL;
Karsten Hopp 361ac5
  		else
Karsten Hopp 361ac5
! 		{
Karsten Hopp 361ac5
! 		    if (VIsual_mode != Ctrl_V)
Karsten Hopp 361ac5
! 			getvvcol(curwin, &(oap->end),
Karsten Hopp 361ac5
! 						  NULL, NULL, &oap->end_vcol);
Karsten Hopp 361ac5
! 		    if (VIsual_mode == Ctrl_V || oap->line_count <= 1)
Karsten Hopp 361ac5
! 		    {
Karsten Hopp 361ac5
! 			if (VIsual_mode != Ctrl_V)
Karsten Hopp 361ac5
! 			    getvvcol(curwin, &(oap->start),
Karsten Hopp 361ac5
! 						&oap->start_vcol, NULL, NULL);
Karsten Hopp 361ac5
! 			resel_VIsual_vcol = oap->end_vcol - oap->start_vcol + 1;
Karsten Hopp 361ac5
! 		    }
Karsten Hopp 361ac5
! 		    else
Karsten Hopp 361ac5
! 			resel_VIsual_vcol = oap->end_vcol;
Karsten Hopp 361ac5
! 		}
Karsten Hopp 361ac5
  		resel_VIsual_line_count = oap->line_count;
Karsten Hopp 361ac5
  	    }
Karsten Hopp 361ac5
  
Karsten Hopp 361ac5
***************
Karsten Hopp 361ac5
*** 1769,1775 ****
Karsten Hopp 361ac5
  		if (!redo_VIsual_busy)
Karsten Hopp 361ac5
  		{
Karsten Hopp 361ac5
  		    redo_VIsual_mode = resel_VIsual_mode;
Karsten Hopp 361ac5
! 		    redo_VIsual_col = resel_VIsual_col;
Karsten Hopp 361ac5
  		    redo_VIsual_line_count = resel_VIsual_line_count;
Karsten Hopp 361ac5
  		    redo_VIsual_count = cap->count0;
Karsten Hopp 361ac5
  		}
Karsten Hopp 361ac5
--- 1787,1793 ----
Karsten Hopp 361ac5
  		if (!redo_VIsual_busy)
Karsten Hopp 361ac5
  		{
Karsten Hopp 361ac5
  		    redo_VIsual_mode = resel_VIsual_mode;
Karsten Hopp 361ac5
! 		    redo_VIsual_vcol = resel_VIsual_vcol;
Karsten Hopp 361ac5
  		    redo_VIsual_line_count = resel_VIsual_line_count;
Karsten Hopp 361ac5
  		    redo_VIsual_count = cap->count0;
Karsten Hopp 361ac5
  		}
Karsten Hopp 361ac5
***************
Karsten Hopp 361ac5
*** 7631,7642 ****
Karsten Hopp 361ac5
  	    if (VIsual_mode == 'v')
Karsten Hopp 361ac5
  	    {
Karsten Hopp 361ac5
  		if (resel_VIsual_line_count <= 1)
Karsten Hopp 361ac5
! 		    curwin->w_cursor.col += resel_VIsual_col * cap->count0 - 1;
Karsten Hopp 361ac5
  		else
Karsten Hopp 361ac5
! 		    curwin->w_cursor.col = resel_VIsual_col;
Karsten Hopp 361ac5
! 		check_cursor_col();
Karsten Hopp 361ac5
  	    }
Karsten Hopp 361ac5
! 	    if (resel_VIsual_col == MAXCOL)
Karsten Hopp 361ac5
  	    {
Karsten Hopp 361ac5
  		curwin->w_curswant = MAXCOL;
Karsten Hopp 361ac5
  		coladvance((colnr_T)MAXCOL);
Karsten Hopp 361ac5
--- 7649,7664 ----
Karsten Hopp 361ac5
  	    if (VIsual_mode == 'v')
Karsten Hopp 361ac5
  	    {
Karsten Hopp 361ac5
  		if (resel_VIsual_line_count <= 1)
Karsten Hopp 361ac5
! 		{
Karsten Hopp 361ac5
! 		    validate_virtcol();
Karsten Hopp 361ac5
! 		    curwin->w_curswant = curwin->w_virtcol
Karsten Hopp 361ac5
! 					+ resel_VIsual_vcol * cap->count0 - 1;
Karsten Hopp 361ac5
! 		}
Karsten Hopp 361ac5
  		else
Karsten Hopp 361ac5
! 		    curwin->w_curswant = resel_VIsual_vcol;
Karsten Hopp 361ac5
! 		coladvance(curwin->w_curswant);
Karsten Hopp 361ac5
  	    }
Karsten Hopp 361ac5
! 	    if (resel_VIsual_vcol == MAXCOL)
Karsten Hopp 361ac5
  	    {
Karsten Hopp 361ac5
  		curwin->w_curswant = MAXCOL;
Karsten Hopp 361ac5
  		coladvance((colnr_T)MAXCOL);
Karsten Hopp 361ac5
***************
Karsten Hopp 361ac5
*** 7645,7651 ****
Karsten Hopp 361ac5
  	    {
Karsten Hopp 361ac5
  		validate_virtcol();
Karsten Hopp 361ac5
  		curwin->w_curswant = curwin->w_virtcol
Karsten Hopp 361ac5
! 					 + resel_VIsual_col * cap->count0 - 1;
Karsten Hopp 361ac5
  		coladvance(curwin->w_curswant);
Karsten Hopp 361ac5
  	    }
Karsten Hopp 361ac5
  	    else
Karsten Hopp 361ac5
--- 7667,7673 ----
Karsten Hopp 361ac5
  	    {
Karsten Hopp 361ac5
  		validate_virtcol();
Karsten Hopp 361ac5
  		curwin->w_curswant = curwin->w_virtcol
Karsten Hopp 361ac5
! 					+ resel_VIsual_vcol * cap->count0 - 1;
Karsten Hopp 361ac5
  		coladvance(curwin->w_curswant);
Karsten Hopp 361ac5
  	    }
Karsten Hopp 361ac5
  	    else
Karsten Hopp 361ac5
*** ../vim-7.3.332/src/version.c	2011-10-04 18:03:43.000000000 +0200
Karsten Hopp 361ac5
--- src/version.c	2011-10-04 21:05:44.000000000 +0200
Karsten Hopp 361ac5
***************
Karsten Hopp 361ac5
*** 711,712 ****
Karsten Hopp 361ac5
--- 711,714 ----
Karsten Hopp 361ac5
  {   /* Add new patch number below this line */
Karsten Hopp 361ac5
+ /**/
Karsten Hopp 361ac5
+     333,
Karsten Hopp 361ac5
  /**/
Karsten Hopp 361ac5
Karsten Hopp 361ac5
-- 
Karsten Hopp 361ac5
It was recently discovered that research causes cancer in rats.
Karsten Hopp 361ac5
Karsten Hopp 361ac5
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 361ac5
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 361ac5
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 361ac5
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///