Bram,
certain normal mode commands change the visual selection type. E.g. 'R' 
or 'S' (because internally, Vim changes the visual mode to 'V' so that 
the command operates linewise. Unfortunately, this breaks 'gv'.

For example, take this mail, visually block select the first column, 
press R, ESC to quit insert mode, u to undo the deletion and now try to 
reselect the save region using 'gv'. You'll notice, it will select the 
same range of lines, but line wise not block wise. This is especially 
annoying, if you by accident hit 'R' instead of 'r' and you must 
reselect the area instead of simply using 'gv'

Attached patch fixes this.

regards,
Christian
-- 

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -21,6 +21,7 @@
 static int	resel_VIsual_mode = NUL;	/* 'v', 'V', or Ctrl-V */
 static linenr_T	resel_VIsual_line_count;	/* number of lines */
 static colnr_T	resel_VIsual_vcol;		/* nr of cols or end col */
+static int	VIsual_mode_orig = NUL;         /* type of Visual mode, that user entered */
 
 static int	restart_VIsual_select = 0;
 #endif
@@ -1594,6 +1595,11 @@
 		curbuf->b_visual.vi_start = VIsual;
 		curbuf->b_visual.vi_end = curwin->w_cursor;
 		curbuf->b_visual.vi_mode = VIsual_mode;
+		if (VIsual_mode_orig != NUL)
+		{
+		    curbuf->b_visual.vi_mode = VIsual_mode_orig;
+		    VIsual_mode_orig = NUL;
+		}
 		curbuf->b_visual.vi_curswant = curwin->w_curswant;
 # ifdef FEAT_EVAL
 		curbuf->b_visual_mode_eval = VIsual_mode;
@@ -7230,6 +7236,7 @@
     {
 	cap->cmdchar = 'c';
 	cap->nchar = NUL;
+	VIsual_mode_orig = VIsual_mode; /* remember original area for gv */
 	VIsual_mode = 'V';
 	nv_operator(cap);
     }
@@ -7429,7 +7436,10 @@
     if (isupper(cap->cmdchar))
     {
 	if (VIsual_mode != Ctrl_V)
+	{
+	    VIsual_mode_orig = VIsual_mode;
 	    VIsual_mode = 'V';
+	}
 	else if (cap->cmdchar == 'C' || cap->cmdchar == 'D')
 	    curwin->w_curswant = MAXCOL;
     }
@@ -7449,7 +7459,10 @@
     if (VIsual_active)	/* "vs" and "vS" are the same as "vc" */
     {
 	if (cap->cmdchar == 'S')
+	{
+	    VIsual_mode_orig = VIsual_mode;
 	    VIsual_mode = 'V';
+	}
 	cap->cmdchar = 'c';
 	nv_operator(cap);
     }

Raspunde prin e-mail lui