Re: Regression: v_b_A inserts at start or middle of selection instead of end after 7.4.576

2015-06-07 Fir de Conversatie Bram Moolenaar

Christian Brabandt wrote:

 On Mo, 18 Mai 2015, Ingo Karkat wrote:
 
  Hello Vim developers,
  
  appending to the end of a visual blockwise selection can be done with
  the A command. I just noticed that this doesn't work reliably any more
  when
  - lines are wrapped and the cursor is in a following screen line AND
  - :set linebreak
  This happens with real blocks as well as a corner case single-line
  blockwise selection.
  To reproduce:
  
  vim -N -u NONE
  :set linebreak
  :normal! 40afoo bar
  :normal! BB^VeAX
  Appending should be after the selected word (barfooX), but it occurs
  at the beginning instead (Xbarfoo).
  
  I've bisected this down to the following patch:
  
  ,[ bad change ]
  | 7.4.576  redrawing problem with 'relativenumber' and 'linebreak'
  `
  
  Attached is a test that verifies the correct behavior.
  
  I can reproduce this on Vim version 7.4.716 on Windows/x64 as well as on
  latest Vim 7.4.729 on Linux/x64.
  
 
 I can reproduce it. Thanks for the feedback. Looks like one needs to 
 recalculate the virtual column numbers after resetting the linebreak 
 option. This also happens for the OP_REPLACE part. Here is a patch, 
 including your testcase.

Thanks for the patch!  Oh, the updated one.

-- 
From know your smileys:
 :-)-O  Smiling doctor with stethoscope

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Regression: v_b_A inserts at start or middle of selection instead of end after 7.4.576

2015-06-01 Fir de Conversatie Christian Brabandt
On Fr, 29 Mai 2015, Ingo Karkat wrote:

 On 28-May-2015 21:14, Christian Brabandt wrote:
  Hi Ingo!
  On Di, 26 Mai 2015, Ingo Karkat wrote:
  
  On 24-May-2015 13:15, Christian Brabandt wrote:
  On Mo, 18 Mai 2015, Ingo Karkat wrote:
 
  Hello Vim developers,
 
  appending to the end of a visual blockwise selection can be done with
  the A command. I just noticed that this doesn't work reliably any more
  when
  - lines are wrapped and the cursor is in a following screen line AND
  - :set linebreak
  This happens with real blocks as well as a corner case single-line
  blockwise selection.
  To reproduce:
 
  vim -N -u NONE
  :set linebreak
  :normal! 40afoo bar
  :normal! BB^VeAX
  Appending should be after the selected word (barfooX), but it occurs
  at the beginning instead (Xbarfoo).
 
  I've bisected this down to the following patch:
 
  ,[ bad change ]
  | 7.4.576  redrawing problem with 'relativenumber' and 'linebreak'
  `
 
  Attached is a test that verifies the correct behavior.
 
  I can reproduce this on Vim version 7.4.716 on Windows/x64 as well as on
  latest Vim 7.4.729 on Linux/x64.
 
 
  I can reproduce it. Thanks for the feedback. Looks like one needs to 
  recalculate the virtual column numbers after resetting the linebreak 
  option. This also happens for the OP_REPLACE part. Here is a patch, 
  including your testcase.
 
  Thank you Christian! Unfortunately, there's still an off-by-one error
  with :set selection=exclusive; the cursor is positioned one character
  left of the selection's end (resulting in barfoXo in the test).
 
  I hope that is easy to fix; it might also be worthwhile to test that
  variation, too.
  
  Updated patch and test attached.
 
 Thank you very much! I can confirm that this indeed fixes the problem,
 with both values of 'selection'. The test with a selection that ends in
 a multibyte character is a good idea, too!

Another update, adding another test, fixing a similar problem with 
change mode

Best,
Christian
-- 
Wenn sie das Maß überschreiten, sind beide bös: der Schlaf und das
Wachen.
-- Hippokrates

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -174,6 +174,7 @@ static void	nv_drop __ARGS((cmdarg_T *ca
 #ifdef FEAT_AUTOCMD
 static void	nv_cursorhold __ARGS((cmdarg_T *cap));
 #endif
+static void	get_op_vcol __ARGS((oparg_T *oap, colnr_T col, int initial));
 
 static char *e_noident = N_(E349: No identifier under cursor);
 
@@ -1418,6 +1419,8 @@ do_pending_operator(cap, old_col, gui_ya
 {
 #ifdef FEAT_LINEBREAK
 	/* Avoid a problem with unwanted linebreaks in block mode. */
+	if (curwin-w_p_lbr)
+	curwin-w_valid = ~VALID_VIRTCOL;
 	curwin-w_p_lbr = FALSE;
 #endif
 	oap-is_VIsual = VIsual_active;
@@ -1629,61 +1632,7 @@ do_pending_operator(cap, old_col, gui_ya
 
 	if (VIsual_active || redo_VIsual_busy)
 	{
-	if (VIsual_mode == Ctrl_V)	/* block mode */
-	{
-		colnr_T	start, end;
-
-		oap-block_mode = TRUE;
-
-		getvvcol(curwin, (oap-start),
-  oap-start_vcol, NULL, oap-end_vcol);
-		if (!redo_VIsual_busy)
-		{
-		getvvcol(curwin, (oap-end), start, NULL, end);
-
-		if (start  oap-start_vcol)
-			oap-start_vcol = start;
-		if (end  oap-end_vcol)
-		{
-			if (*p_sel == 'e'  start = 1
-		 start - 1 = oap-end_vcol)
-			oap-end_vcol = start - 1;
-			else
-			oap-end_vcol = end;
-		}
-		}
-
-		/* if '$' was used, get oap-end_vcol from longest line */
-		if (curwin-w_curswant == MAXCOL)
-		{
-		curwin-w_cursor.col = MAXCOL;
-		oap-end_vcol = 0;
-		for (curwin-w_cursor.lnum = oap-start.lnum;
-			curwin-w_cursor.lnum = oap-end.lnum;
-		  ++curwin-w_cursor.lnum)
-		{
-			getvvcol(curwin, curwin-w_cursor, NULL, NULL, end);
-			if (end  oap-end_vcol)
-			oap-end_vcol = end;
-		}
-		}
-		else if (redo_VIsual_busy)
-		oap-end_vcol = oap-start_vcol + redo_VIsual_vcol - 1;
-		/*
-		 * Correct oap-end.col and oap-start.col to be the
-		 * upper-left and lower-right corner of the block area.
-		 *
-		 * (Actually, this does convert column positions into character
-		 * positions)
-		 */
-		curwin-w_cursor.lnum = oap-end.lnum;
-		coladvance(oap-end_vcol);
-		oap-end = curwin-w_cursor;
-
-		curwin-w_cursor = oap-start;
-		coladvance(oap-start_vcol);
-		oap-start = curwin-w_cursor;
-	}
+	get_op_vcol(oap, redo_VIsual_vcol, TRUE);
 
 	if (!redo_VIsual_busy  !gui_yank)
 	{
@@ -1988,7 +1937,11 @@ do_pending_operator(cap, old_col, 

Re: Regression: v_b_A inserts at start or middle of selection instead of end after 7.4.576

2015-05-29 Fir de Conversatie Ingo Karkat
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 28-May-2015 21:14, Christian Brabandt wrote:
 Hi Ingo!
 On Di, 26 Mai 2015, Ingo Karkat wrote:
 
 On 24-May-2015 13:15, Christian Brabandt wrote:
 On Mo, 18 Mai 2015, Ingo Karkat wrote:

 Hello Vim developers,

 appending to the end of a visual blockwise selection can be done with
 the A command. I just noticed that this doesn't work reliably any more
 when
 - lines are wrapped and the cursor is in a following screen line AND
 - :set linebreak
 This happens with real blocks as well as a corner case single-line
 blockwise selection.
 To reproduce:

 vim -N -u NONE
 :set linebreak
 :normal! 40afoo bar
 :normal! BB^VeAX
 Appending should be after the selected word (barfooX), but it occurs
 at the beginning instead (Xbarfoo).

 I've bisected this down to the following patch:

 ,[ bad change ]
 | 7.4.576  redrawing problem with 'relativenumber' and 'linebreak'
 `

 Attached is a test that verifies the correct behavior.

 I can reproduce this on Vim version 7.4.716 on Windows/x64 as well as on
 latest Vim 7.4.729 on Linux/x64.


 I can reproduce it. Thanks for the feedback. Looks like one needs to 
 recalculate the virtual column numbers after resetting the linebreak 
 option. This also happens for the OP_REPLACE part. Here is a patch, 
 including your testcase.

 Thank you Christian! Unfortunately, there's still an off-by-one error
 with :set selection=exclusive; the cursor is positioned one character
 left of the selection's end (resulting in barfoXo in the test).

 I hope that is easy to fix; it might also be worthwhile to test that
 variation, too.
 
 Updated patch and test attached.

Thank you very much! I can confirm that this indeed fixes the problem,
with both values of 'selection'. The test with a selection that ends in
a multibyte character is a good idea, too!

- -- regards, ingo
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (MingW32)

iQEcBAEBAgAGBQJVaBfgAAoJEA7ziXlAzQ/vWncH/RD1olqSK+ROsGLesaaB1+UV
L611Wwe/EOYXZ5Wmtvl2peP8DxXPfsJnz3kW09Jl/KmquMb7QqicqX9sflcJyAin
nA2m390mItXPHm1cCZIF9Q2oNcILSlEumjM0I0dRfD+ioNMYpTN6GFWa7XtOG1i2
9wcCDB7SWuh/nDqi5HOKJR+QFP91jSg4rWN+jn22ehTDC9BH5NFq7kf6MYNbQH/Y
aQo61fbEopnf1sc6JhGyKhYCxebSWNoolvK7Mq8UtVm+yeKLcBbIEFhLxh/2qKyZ
fPvP3Yjb69ZBmGkFBhmf6gbso7iVWeBPv9NJ9pY950b7NVkvEZmCryW2xZv8+k8=
=y9pv
-END PGP SIGNATURE-

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Regression: v_b_A inserts at start or middle of selection instead of end after 7.4.576

2015-05-28 Fir de Conversatie Christian Brabandt
Hi Ingo!

On Di, 26 Mai 2015, Ingo Karkat wrote:

 On 24-May-2015 13:15, Christian Brabandt wrote:
  On Mo, 18 Mai 2015, Ingo Karkat wrote:
  
  Hello Vim developers,
 
  appending to the end of a visual blockwise selection can be done with
  the A command. I just noticed that this doesn't work reliably any more
  when
  - lines are wrapped and the cursor is in a following screen line AND
  - :set linebreak
  This happens with real blocks as well as a corner case single-line
  blockwise selection.
  To reproduce:
 
  vim -N -u NONE
  :set linebreak
  :normal! 40afoo bar
  :normal! BB^VeAX
  Appending should be after the selected word (barfooX), but it occurs
  at the beginning instead (Xbarfoo).
 
  I've bisected this down to the following patch:
 
  ,[ bad change ]
  | 7.4.576  redrawing problem with 'relativenumber' and 'linebreak'
  `
 
  Attached is a test that verifies the correct behavior.
 
  I can reproduce this on Vim version 7.4.716 on Windows/x64 as well as on
  latest Vim 7.4.729 on Linux/x64.
 
  
  I can reproduce it. Thanks for the feedback. Looks like one needs to 
  recalculate the virtual column numbers after resetting the linebreak 
  option. This also happens for the OP_REPLACE part. Here is a patch, 
  including your testcase.
 
 Thank you Christian! Unfortunately, there's still an off-by-one error
 with :set selection=exclusive; the cursor is positioned one character
 left of the selection's end (resulting in barfoXo in the test).
 
 I hope that is easy to fix; it might also be worthwhile to test that
 variation, too.

Updated patch and test attached.

Best,
Christian
-- 
Mit Adleraugen sehen wir die Fehler anderer, mit Maulwurfaugen unsere
eigenen.
-- Franz von Sales

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -174,6 +174,7 @@ static void	nv_drop __ARGS((cmdarg_T *ca
 #ifdef FEAT_AUTOCMD
 static void	nv_cursorhold __ARGS((cmdarg_T *cap));
 #endif
+static void	get_op_vcol __ARGS((oparg_T *oap, colnr_T col, int adjust_sel));
 
 static char *e_noident = N_(E349: No identifier under cursor);
 
@@ -1629,61 +1630,7 @@ do_pending_operator(cap, old_col, gui_ya
 
 	if (VIsual_active || redo_VIsual_busy)
 	{
-	if (VIsual_mode == Ctrl_V)	/* block mode */
-	{
-		colnr_T	start, end;
-
-		oap-block_mode = TRUE;
-
-		getvvcol(curwin, (oap-start),
-  oap-start_vcol, NULL, oap-end_vcol);
-		if (!redo_VIsual_busy)
-		{
-		getvvcol(curwin, (oap-end), start, NULL, end);
-
-		if (start  oap-start_vcol)
-			oap-start_vcol = start;
-		if (end  oap-end_vcol)
-		{
-			if (*p_sel == 'e'  start = 1
-		 start - 1 = oap-end_vcol)
-			oap-end_vcol = start - 1;
-			else
-			oap-end_vcol = end;
-		}
-		}
-
-		/* if '$' was used, get oap-end_vcol from longest line */
-		if (curwin-w_curswant == MAXCOL)
-		{
-		curwin-w_cursor.col = MAXCOL;
-		oap-end_vcol = 0;
-		for (curwin-w_cursor.lnum = oap-start.lnum;
-			curwin-w_cursor.lnum = oap-end.lnum;
-		  ++curwin-w_cursor.lnum)
-		{
-			getvvcol(curwin, curwin-w_cursor, NULL, NULL, end);
-			if (end  oap-end_vcol)
-			oap-end_vcol = end;
-		}
-		}
-		else if (redo_VIsual_busy)
-		oap-end_vcol = oap-start_vcol + redo_VIsual_vcol - 1;
-		/*
-		 * Correct oap-end.col and oap-start.col to be the
-		 * upper-left and lower-right corner of the block area.
-		 *
-		 * (Actually, this does convert column positions into character
-		 * positions)
-		 */
-		curwin-w_cursor.lnum = oap-end.lnum;
-		coladvance(oap-end_vcol);
-		oap-end = curwin-w_cursor;
-
-		curwin-w_cursor = oap-start;
-		coladvance(oap-start_vcol);
-		oap-start = curwin-w_cursor;
-	}
+	get_op_vcol(oap, redo_VIsual_vcol, TRUE);
 
 	if (!redo_VIsual_busy  !gui_yank)
 	{
@@ -2088,7 +2035,11 @@ do_pending_operator(cap, old_col, gui_ya
 #ifdef FEAT_LINEBREAK
 		/* Restore linebreak, so that when the user edits it looks as
 		 * before. */
-		curwin-w_p_lbr = lbr_saved;
+		if (curwin-w_p_lbr != lbr_saved)
+		{
+		curwin-w_p_lbr = lbr_saved;
+		get_op_vcol(oap, redo_VIsual_mode, FALSE);
+		}
 #endif
 		op_insert(oap, cap-count1);
 #ifdef FEAT_LINEBREAK
@@ -2123,7 +2074,11 @@ do_pending_operator(cap, old_col, gui_ya
 #ifdef FEAT_LINEBREAK
 		/* Restore linebreak, so that when the user edits it looks as
 		 * before. */
-		curwin-w_p_lbr = lbr_saved;
+		if (curwin-w_p_lbr != lbr_saved)
+		{
+		curwin-w_p_lbr = lbr_saved;
+		get_op_vcol(oap, redo_VIsual_mode, 

Re: Regression: v_b_A inserts at start or middle of selection instead of end after 7.4.576

2015-05-26 Fir de Conversatie Ingo Karkat
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 24-May-2015 13:15, Christian Brabandt wrote:
 On Mo, 18 Mai 2015, Ingo Karkat wrote:
 
 Hello Vim developers,

 appending to the end of a visual blockwise selection can be done with
 the A command. I just noticed that this doesn't work reliably any more
 when
 - lines are wrapped and the cursor is in a following screen line AND
 - :set linebreak
 This happens with real blocks as well as a corner case single-line
 blockwise selection.
 To reproduce:

 vim -N -u NONE
 :set linebreak
 :normal! 40afoo bar
 :normal! BB^VeAX
 Appending should be after the selected word (barfooX), but it occurs
 at the beginning instead (Xbarfoo).

 I've bisected this down to the following patch:

 ,[ bad change ]
 | 7.4.576  redrawing problem with 'relativenumber' and 'linebreak'
 `

 Attached is a test that verifies the correct behavior.

 I can reproduce this on Vim version 7.4.716 on Windows/x64 as well as on
 latest Vim 7.4.729 on Linux/x64.

 
 I can reproduce it. Thanks for the feedback. Looks like one needs to 
 recalculate the virtual column numbers after resetting the linebreak 
 option. This also happens for the OP_REPLACE part. Here is a patch, 
 including your testcase.

Thank you Christian! Unfortunately, there's still an off-by-one error
with :set selection=exclusive; the cursor is positioned one character
left of the selection's end (resulting in barfoXo in the test).

I hope that is easy to fix; it might also be worthwhile to test that
variation, too.

- -- regards, ingo

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (MingW32)

iQEcBAEBAgAGBQJVZJrWAAoJEA7ziXlAzQ/vjNYH/3dBvD8VuYlIdUx8bLwYhPZ5
Iba4jI/sf63UQpRY2UsYU+TDiTIHF/odFv1Wc+5+YshuUQoEvB8n+SgpO/HCTBSu
UPscktn6K/f2cJ5l6d+VP2D/ZCiO+WLhnPAC4nTN5rAImtKfVxcEU3EhqpRt6745
l2/A6TQVlRbW6P7SE+PUsFVnBpUumdLMEJ/9fKYHBH31QqDPdSNyvhq4h+rGOWCC
I2KFbE24gykd3C3oKxId1GOSfsS077fzPFMjMaqd90KN68zYn7Y083UghmSWnxbm
DPOaydwWo5i6S5GxWxo17ydIFXAHjAZPsN/7SsyNNJbr57H7ktADvsMcdtjfvjI=
=mLDv
-END PGP SIGNATURE-

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Regression: v_b_A inserts at start or middle of selection instead of end after 7.4.576

2015-05-24 Fir de Conversatie Christian Brabandt
On Mo, 18 Mai 2015, Ingo Karkat wrote:

 Hello Vim developers,
 
 appending to the end of a visual blockwise selection can be done with
 the A command. I just noticed that this doesn't work reliably any more
 when
 - lines are wrapped and the cursor is in a following screen line AND
 - :set linebreak
 This happens with real blocks as well as a corner case single-line
 blockwise selection.
 To reproduce:
 
 vim -N -u NONE
 :set linebreak
 :normal! 40afoo bar
 :normal! BB^VeAX
 Appending should be after the selected word (barfooX), but it occurs
 at the beginning instead (Xbarfoo).
 
 I've bisected this down to the following patch:
 
 ,[ bad change ]
 | 7.4.576  redrawing problem with 'relativenumber' and 'linebreak'
 `
 
 Attached is a test that verifies the correct behavior.
 
 I can reproduce this on Vim version 7.4.716 on Windows/x64 as well as on
 latest Vim 7.4.729 on Linux/x64.
 

I can reproduce it. Thanks for the feedback. Looks like one needs to 
recalculate the virtual column numbers after resetting the linebreak 
option. This also happens for the OP_REPLACE part. Here is a patch, 
including your testcase.

Best,
Christian
-- 
Wie man sein Kind nicht nennen sollte: 
  Kris Tal 

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -174,6 +174,7 @@ static void	nv_drop __ARGS((cmdarg_T *ca
 #ifdef FEAT_AUTOCMD
 static void	nv_cursorhold __ARGS((cmdarg_T *cap));
 #endif
+static void	get_op_vcol __ARGS((oparg_T *oap, colnr_T col));
 
 static char *e_noident = N_(E349: No identifier under cursor);
 
@@ -1629,61 +1630,7 @@ do_pending_operator(cap, old_col, gui_ya
 
 	if (VIsual_active || redo_VIsual_busy)
 	{
-	if (VIsual_mode == Ctrl_V)	/* block mode */
-	{
-		colnr_T	start, end;
-
-		oap-block_mode = TRUE;
-
-		getvvcol(curwin, (oap-start),
-  oap-start_vcol, NULL, oap-end_vcol);
-		if (!redo_VIsual_busy)
-		{
-		getvvcol(curwin, (oap-end), start, NULL, end);
-
-		if (start  oap-start_vcol)
-			oap-start_vcol = start;
-		if (end  oap-end_vcol)
-		{
-			if (*p_sel == 'e'  start = 1
-		 start - 1 = oap-end_vcol)
-			oap-end_vcol = start - 1;
-			else
-			oap-end_vcol = end;
-		}
-		}
-
-		/* if '$' was used, get oap-end_vcol from longest line */
-		if (curwin-w_curswant == MAXCOL)
-		{
-		curwin-w_cursor.col = MAXCOL;
-		oap-end_vcol = 0;
-		for (curwin-w_cursor.lnum = oap-start.lnum;
-			curwin-w_cursor.lnum = oap-end.lnum;
-		  ++curwin-w_cursor.lnum)
-		{
-			getvvcol(curwin, curwin-w_cursor, NULL, NULL, end);
-			if (end  oap-end_vcol)
-			oap-end_vcol = end;
-		}
-		}
-		else if (redo_VIsual_busy)
-		oap-end_vcol = oap-start_vcol + redo_VIsual_vcol - 1;
-		/*
-		 * Correct oap-end.col and oap-start.col to be the
-		 * upper-left and lower-right corner of the block area.
-		 *
-		 * (Actually, this does convert column positions into character
-		 * positions)
-		 */
-		curwin-w_cursor.lnum = oap-end.lnum;
-		coladvance(oap-end_vcol);
-		oap-end = curwin-w_cursor;
-
-		curwin-w_cursor = oap-start;
-		coladvance(oap-start_vcol);
-		oap-start = curwin-w_cursor;
-	}
+	get_op_vcol(oap, redo_VIsual_vcol);
 
 	if (!redo_VIsual_busy  !gui_yank)
 	{
@@ -2088,7 +2035,11 @@ do_pending_operator(cap, old_col, gui_ya
 #ifdef FEAT_LINEBREAK
 		/* Restore linebreak, so that when the user edits it looks as
 		 * before. */
-		curwin-w_p_lbr = lbr_saved;
+		if (curwin-w_p_lbr != lbr_saved)
+		{
+		curwin-w_p_lbr = lbr_saved;
+		get_op_vcol(oap, redo_VIsual_mode);
+		}
 #endif
 		op_insert(oap, cap-count1);
 #ifdef FEAT_LINEBREAK
@@ -2123,7 +2074,11 @@ do_pending_operator(cap, old_col, gui_ya
 #ifdef FEAT_LINEBREAK
 		/* Restore linebreak, so that when the user edits it looks as
 		 * before. */
-		curwin-w_p_lbr = lbr_saved;
+		if (curwin-w_p_lbr != lbr_saved)
+		{
+		curwin-w_p_lbr = lbr_saved;
+		get_op_vcol(oap, redo_VIsual_mode);
+		}
 #endif
 		op_replace(oap, cap-nchar);
 	}
@@ -9543,3 +9498,63 @@ nv_cursorhold(cap)
 cap-retval |= CA_COMMAND_BUSY;	/* don't call edit() now */
 }
 #endif
+
+/*
+ * calculate start/end virtual columns for operating in block mode
+ */
+static void
+get_op_vcol(oap, redo_VIsual_vcol)
+oparg_T	*oap;
+colnr_T	redo_VIsual_vcol;
+{
+colnr_T	start, end;
+
+if (VIsual_mode != Ctrl_V)
+	return;
+
+oap-block_mode = TRUE;
+
+getvvcol(curwin, (oap-start), oap-start_vcol, NULL, oap-end_vcol);
+getvvcol(curwin, 

Regression: v_b_A inserts at start or middle of selection instead of end after 7.4.576

2015-05-18 Fir de Conversatie Ingo Karkat
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello Vim developers,

appending to the end of a visual blockwise selection can be done with
the A command. I just noticed that this doesn't work reliably any more
when
- - lines are wrapped and the cursor is in a following screen line AND
- - :set linebreak
This happens with real blocks as well as a corner case single-line
blockwise selection.
To reproduce:

vim -N -u NONE
:set linebreak
:normal! 40afoo bar
:normal! BB^VeAX
Appending should be after the selected word (barfooX), but it occurs
at the beginning instead (Xbarfoo).

I've bisected this down to the following patch:

,[ bad change ]
| 7.4.576  redrawing problem with 'relativenumber' and 'linebreak'
`

Attached is a test that verifies the correct behavior.

I can reproduce this on Vim version 7.4.716 on Windows/x64 as well as on
latest Vim 7.4.729 on Linux/x64.

- -- regards, ingo
- -- 
  -- Ingo Karkat --  /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
  --   http://vim.sourceforge.net/account/profile.php?user_id=9713   --
Using Vim for 13 years now, mostly 'cos I can't figure out how to exit it.
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (MingW32)

iQEcBAEBAgAGBQJVWgMvAAoJEA7ziXlAzQ/vfFcIAIJ1pWeK7OkasA1NZ2vfn+qw
C/XoykrtUeJe8tTkir16Uqx0pZpVhxgpiMXcyV+g6ul+F5YANZTrbgEsykJ7p1bm
4yFq8XT7ga5zGAHyRJ46sGBdIDlfNHposI6GhXqEj5dKl2JomMt0G2wA+F8nMBY7
15cDhv10pRJrd+KLl9TEnvjDY+IiBrTMv3xpqN5j0o8V0JRjtwDuodRi6TdVNkyN
Fi5o5eMA1cmx9S0nJW376P3XWMowimivRH8Hzrkby/gBaE1YBoE1zUtgFSojI1Pj
uqQ9qF9Lf4ciuLsf+SrsMP8pZ/q0oYL0rnwtOll4tnjXmt8CQF6a/bwpxqlQaus=
=TXsw
-END PGP SIGNATURE-

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/testdir/test39.in b/src/testdir/test39.in
--- a/src/testdir/test39.in
+++ b/src/testdir/test39.in
@@ -51,6 +51,12 @@ G$khhhhhkkcmno
 :exe :norm! 012l\C-vjjAx\Esc
 :set ve= enc=latin1
 :.,/^$/w  test.out
+: Test for single-line Visual block append at wrapped line with :set linebreak
+Golong line: 40afoobar aTARGET at end
+:set linebreak
+:exe :norm! $3B\C-veAx\Esc
+:set nolinebreak
+:.w  test.out
 : gUe must uppercase a whole word, also when ß changes to SS
 Gothe youtußeuu endYpk0wgUe
 : gUfx must uppercase until x, inclusive.
diff --git a/src/testdir/test39.ok b/src/testdir/test39.ok
--- a/src/testdir/test39.ok
+++ b/src/testdir/test39.ok
@@ -30,6 +30,7 @@
x x   line2
x x   line3
 
+long line: foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar TARGETx at end
 the YOUTUSSEUU end
 - yOUSSTUSSEXu -
 THE YOUTUSSEUU END


test-v_b_A in wrapped line.patch.sig
Description: Binary data