Skip to content

Commit 8f53166

Browse files
committed
patch 9.0.1273: "1v" may select block with wrong size
Problem: "1v" may select block with wrong size. (Evgeni Chasnovski) Solution: Compute "curswant" in the right line. (closes #11925)
1 parent e8d4ae0 commit 8f53166

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/normal.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5493,8 +5493,13 @@ nv_visual(cmdarg_T *cap)
54935493
}
54945494
else if (VIsual_mode == Ctrl_V)
54955495
{
5496+
// Update curswant on the original line, that is where "col" is
5497+
// valid.
5498+
linenr_T lnum = curwin->w_cursor.lnum;
5499+
curwin->w_cursor.lnum = VIsual.lnum;
54965500
update_curswant_force();
5497-
curwin->w_curswant += + resel_VIsual_vcol * cap->count0 - 1;
5501+
curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1;
5502+
curwin->w_cursor.lnum = lnum;
54985503
coladvance(curwin->w_curswant);
54995504
}
55005505
else

src/testdir/test_visual.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,17 @@ func Test_visual_block_with_substitute()
13181318
endfunc
13191319

13201320
func Test_visual_reselect_with_count()
1321+
enew
1322+
call setline(1, ['aaaaaa', '✗ bbbb', '✗ bbbb'])
1323+
exe "normal! 2Gw\<C-V>jed"
1324+
exe "normal! gg0lP"
1325+
call assert_equal(['abbbbaaaaa', '✗bbbb ', ''], getline(1, '$'))
1326+
1327+
exe "normal! 1vr."
1328+
call assert_equal(['a....aaaaa', '✗.... ', ''], getline(1, '$'))
1329+
1330+
bwipe!
1331+
13211332
" this was causing an illegal memory access
13221333
let lines =<< trim END
13231334

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1273,
698700
/**/
699701
1272,
700702
/**/

0 commit comments

Comments
 (0)