patch 9.1.1175: inconsistent behaviour with exclusive selection and motion commands
Problem: inconsistent behaviour with exclusive selection and motion
commands (aidancz)
Solution: adjust cursor position when selection is exclusive
(Jim Zhou)
fixes: #16278
closes: #16784
Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Jim Zhou <jimzhouzzy@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
b34ce3e205
commit
c8cce711dd
17
src/normal.c
17
src/normal.c
@ -1130,6 +1130,7 @@ call_yank_do_autocmd(int regname)
|
||||
void
|
||||
end_visual_mode(void)
|
||||
{
|
||||
VIsual_select_exclu_adj = FALSE;
|
||||
end_visual_mode_keep_button();
|
||||
reset_held_button();
|
||||
}
|
||||
@ -4248,6 +4249,15 @@ normal_search(
|
||||
nv_csearch(cmdarg_T *cap)
|
||||
{
|
||||
int t_cmd;
|
||||
int cursor_dec = FALSE;
|
||||
|
||||
// If adjusted cursor position previously, unadjust it.
|
||||
if (*p_sel == 'e' && VIsual_active && VIsual_mode == 'v'
|
||||
&& VIsual_select_exclu_adj)
|
||||
{
|
||||
unadjust_for_sel();
|
||||
cursor_dec = TRUE;
|
||||
}
|
||||
|
||||
if (cap->cmdchar == 't' || cap->cmdchar == 'T')
|
||||
t_cmd = TRUE;
|
||||
@ -4258,6 +4268,9 @@ nv_csearch(cmdarg_T *cap)
|
||||
if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL)
|
||||
{
|
||||
clearopbeep(cap->oap);
|
||||
// Revert unadjust when failed.
|
||||
if (cursor_dec)
|
||||
adjust_for_sel(cap);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5534,6 +5547,8 @@ nv_visual(cmdarg_T *cap)
|
||||
n_start_visual_mode(cap->cmdchar);
|
||||
if (VIsual_mode != 'V' && *p_sel == 'e')
|
||||
++cap->count1; // include one more char
|
||||
else
|
||||
VIsual_select_exclu_adj = FALSE;
|
||||
if (cap->count0 > 0 && --cap->count1 > 0)
|
||||
{
|
||||
// With a count select that many characters or lines.
|
||||
@ -6703,6 +6718,7 @@ adjust_for_sel(cmdarg_T *cap)
|
||||
else
|
||||
++curwin->w_cursor.col;
|
||||
cap->oap->inclusive = FALSE;
|
||||
VIsual_select_exclu_adj = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6728,6 +6744,7 @@ unadjust_for_sel(void)
|
||||
unadjust_for_sel_inner(pos_T *pp)
|
||||
{
|
||||
colnr_T cs, ce;
|
||||
VIsual_select_exclu_adj = FALSE;
|
||||
|
||||
if (pp->coladd > 0)
|
||||
--pp->coladd;
|
||||
|
||||
Reference in New Issue
Block a user