Skip to content

Commit db0eede

Browse files
committed
patch 8.0.1765: CTRL-G j in Insert mode is incorrect when 'virtualedit' set
Problem: CTRL-G j in Insert mode is incorrect when 'virtualedit' is set. Solution: Take coladd into account. (Christian Brabandt, closes #2743)
1 parent 856905b commit db0eede

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/charset.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,12 @@ getvcol_nolist(pos_T *posp)
14171417
colnr_T vcol;
14181418

14191419
curwin->w_p_list = FALSE;
1420-
getvcol(curwin, posp, NULL, &vcol, NULL);
1420+
#ifdef FEAT_VIRTUALEDIT
1421+
if (posp->coladd)
1422+
getvvcol(curwin, posp, NULL, &vcol, NULL);
1423+
else
1424+
#endif
1425+
getvcol(curwin, posp, NULL, &vcol, NULL);
14211426
curwin->w_p_list = list_save;
14221427
return vcol;
14231428
}

src/testdir/test_virtualedit.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ func Test_paste_end_of_line()
3838
exe "normal! 2G$lllA\<C-O>:normal! \"agP\r"
3939
call assert_equal('123456', getline(2))
4040

41+
bwipe!
42+
set virtualedit=
43+
endfunc
44+
45+
func Test_edit_CTRL_G()
46+
new
47+
set virtualedit=insert
48+
call setline(1, ['123', '1', '12'])
49+
exe "normal! ggA\<c-g>jx\<c-g>jx"
50+
call assert_equal(['123', '1 x', '12 x'], getline(1,'$'))
51+
52+
set virtualedit=all
53+
%d_
54+
call setline(1, ['1', '12'])
55+
exe "normal! ggllix\<c-g>jx"
56+
call assert_equal(['1 x', '12x'], getline(1,'$'))
57+
58+
4159
bwipe!
4260
set virtualedit=
4361
endfunc

src/version.c

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

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1765,
764766
/**/
765767
1764,
766768
/**/

0 commit comments

Comments
 (0)