mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.0963: number increment/decrement does not work with 'virtualedit'
Problem: Number increment/decrement does not work with 'virtualedit'. Solution: Handle coladd changing. (Christian Brabandt, closes #6240, closes #923)
This commit is contained in:
parent
f6e020b122
commit
6c6be9e88d
@ -8556,8 +8556,6 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
*'virtualedit'* *'ve'*
|
*'virtualedit'* *'ve'*
|
||||||
'virtualedit' 've' string (default "")
|
'virtualedit' 've' string (default "")
|
||||||
global
|
global
|
||||||
{not available when compiled without the
|
|
||||||
|+virtualedit| feature}
|
|
||||||
A comma separated list of these words:
|
A comma separated list of these words:
|
||||||
block Allow virtual editing in Visual block mode.
|
block Allow virtual editing in Visual block mode.
|
||||||
insert Allow virtual editing in Insert mode.
|
insert Allow virtual editing in Insert mode.
|
||||||
|
@ -470,7 +470,7 @@ B *+vartabs* Variable-width tabstops. |'vartabstop'|
|
|||||||
N *+viminfo* |'viminfo'|
|
N *+viminfo* |'viminfo'|
|
||||||
*+vertsplit* Vertically split windows |:vsplit|; Always enabled
|
*+vertsplit* Vertically split windows |:vsplit|; Always enabled
|
||||||
since 8.0.1118.
|
since 8.0.1118.
|
||||||
N *+virtualedit* |'virtualedit'|
|
N *+virtualedit* |'virtualedit'| Always enabled since 8.1.826.
|
||||||
T *+visual* Visual mode |Visual-mode| Always enabled since 7.4.200.
|
T *+visual* Visual mode |Visual-mode| Always enabled since 7.4.200.
|
||||||
T *+visualextra* extra Visual mode commands |blockwise-operators|
|
T *+visualextra* extra Visual mode commands |blockwise-operators|
|
||||||
T *+vreplace* |gR| and |gr|
|
T *+vreplace* |gR| and |gr|
|
||||||
|
11
src/ops.c
11
src/ops.c
@ -2446,6 +2446,7 @@ do_addsub(
|
|||||||
int maxlen = 0;
|
int maxlen = 0;
|
||||||
pos_T startpos;
|
pos_T startpos;
|
||||||
pos_T endpos;
|
pos_T endpos;
|
||||||
|
colnr_T save_coladd = 0;
|
||||||
|
|
||||||
do_hex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); // "heX"
|
do_hex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); // "heX"
|
||||||
do_oct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); // "Octal"
|
do_oct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); // "Octal"
|
||||||
@ -2453,11 +2454,17 @@ do_addsub(
|
|||||||
do_alpha = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); // "alPha"
|
do_alpha = (vim_strchr(curbuf->b_p_nf, 'p') != NULL); // "alPha"
|
||||||
do_unsigned = (vim_strchr(curbuf->b_p_nf, 'u') != NULL); // "Unsigned"
|
do_unsigned = (vim_strchr(curbuf->b_p_nf, 'u') != NULL); // "Unsigned"
|
||||||
|
|
||||||
|
if (virtual_active())
|
||||||
|
{
|
||||||
|
save_coladd = pos->coladd;
|
||||||
|
pos->coladd = 0;
|
||||||
|
}
|
||||||
|
|
||||||
curwin->w_cursor = *pos;
|
curwin->w_cursor = *pos;
|
||||||
ptr = ml_get(pos->lnum);
|
ptr = ml_get(pos->lnum);
|
||||||
col = pos->col;
|
col = pos->col;
|
||||||
|
|
||||||
if (*ptr == NUL)
|
if (*ptr == NUL || col + !!save_coladd >= (int)STRLEN(ptr))
|
||||||
goto theend;
|
goto theend;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2824,6 +2831,8 @@ theend:
|
|||||||
curwin->w_cursor = save_cursor;
|
curwin->w_cursor = save_cursor;
|
||||||
else if (did_change)
|
else if (did_change)
|
||||||
curwin->w_set_curswant = TRUE;
|
curwin->w_set_curswant = TRUE;
|
||||||
|
else if (virtual_active())
|
||||||
|
curwin->w_cursor.coladd = save_coladd;
|
||||||
|
|
||||||
return did_change;
|
return did_change;
|
||||||
}
|
}
|
||||||
|
@ -840,4 +840,40 @@ func Test_increment_unsigned()
|
|||||||
set nrformats-=unsigned
|
set nrformats-=unsigned
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_normal_increment_with_virtualedit()
|
||||||
|
set virtualedit=all
|
||||||
|
|
||||||
|
call setline(1, ["\<TAB>1"])
|
||||||
|
exec "norm! 0\<C-A>"
|
||||||
|
call assert_equal("\<TAB>2", getline(1))
|
||||||
|
call assert_equal([0, 1, 2, 0], getpos('.'))
|
||||||
|
|
||||||
|
call setline(1, ["\<TAB>1"])
|
||||||
|
exec "norm! 0l\<C-A>"
|
||||||
|
call assert_equal("\<TAB>2", getline(1))
|
||||||
|
call assert_equal([0, 1, 2, 0], getpos('.'))
|
||||||
|
|
||||||
|
call setline(1, ["\<TAB>1"])
|
||||||
|
exec "norm! 07l\<C-A>"
|
||||||
|
call assert_equal("\<TAB>2", getline(1))
|
||||||
|
call assert_equal([0, 1, 2, 0], getpos('.'))
|
||||||
|
|
||||||
|
call setline(1, ["\<TAB>1"])
|
||||||
|
exec "norm! 0w\<C-A>"
|
||||||
|
call assert_equal("\<TAB>2", getline(1))
|
||||||
|
call assert_equal([0, 1, 2, 0], getpos('.'))
|
||||||
|
|
||||||
|
call setline(1, ["\<TAB>1"])
|
||||||
|
exec "norm! 0wl\<C-A>"
|
||||||
|
call assert_equal("\<TAB>1", getline(1))
|
||||||
|
call assert_equal([0, 1, 3, 0], getpos('.'))
|
||||||
|
|
||||||
|
call setline(1, ["\<TAB>1"])
|
||||||
|
exec "norm! 0w30l\<C-A>"
|
||||||
|
call assert_equal("\<TAB>1", getline(1))
|
||||||
|
call assert_equal([0, 1, 3, 29], getpos('.'))
|
||||||
|
|
||||||
|
set virtualedit&
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
963,
|
||||||
/**/
|
/**/
|
||||||
962,
|
962,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user