0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.1.0433: Wrong yanking with exclusive selection and ve=all

Problem:  Wrong yanking with exclusive selection and virtualedit=all,
          and integer overflow when using getregion() on it.
Solution: Set coladd when decreasing column and 'virtualedit' is active.
          Add more tests for getregion() with 'virtualedit' (zeertzjq).

closes: #14830

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-05-23 07:47:55 +02:00
committed by Christian Brabandt
parent f2d74e3b63
commit 701ad50a9e
5 changed files with 228 additions and 44 deletions

View File

@@ -6696,29 +6696,40 @@ adjust_for_sel(cmdarg_T *cap)
int
unadjust_for_sel(void)
{
pos_T *pp;
if (*p_sel == 'e' && !EQUAL_POS(VIsual, curwin->w_cursor))
return unadjust_for_sel_inner(LT_POS(VIsual, curwin->w_cursor)
? &curwin->w_cursor : &VIsual);
return FALSE;
}
/*
* Move position "*pp" back one character for 'selection' == "exclusive".
* Returns TRUE when backed up to the previous line.
*/
int
unadjust_for_sel_inner(pos_T *pp)
{
colnr_T cs, ce;
if (pp->coladd > 0)
--pp->coladd;
else if (pp->col > 0)
{
if (LT_POS(VIsual, curwin->w_cursor))
pp = &curwin->w_cursor;
else
pp = &VIsual;
if (pp->coladd > 0)
--pp->coladd;
else
if (pp->col > 0)
--pp->col;
mb_adjustpos(curbuf, pp);
if (virtual_active())
{
--pp->col;
mb_adjustpos(curbuf, pp);
}
else if (pp->lnum > 1)
{
--pp->lnum;
pp->col = ml_get_len(pp->lnum);
return TRUE;
getvcol(curwin, pp, &cs, NULL, &ce);
pp->coladd = ce - cs;
}
}
else if (pp->lnum > 1)
{
--pp->lnum;
pp->col = ml_get_len(pp->lnum);
return TRUE;
}
return FALSE;
}