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>
diff --git a/src/evalfunc.c b/src/evalfunc.c
index b65df5d..f70b032 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -5594,31 +5594,12 @@
if (*region_type == MCHAR)
{
- // handle 'selection' == "exclusive"
+ // Handle 'selection' == "exclusive".
if (is_select_exclusive && !EQUAL_POS(*p1, *p2))
- {
- if (p2->coladd > 0)
- p2->coladd--;
- else if (p2->col > 0)
- {
- p2->col--;
-
- mb_adjustpos(curbuf, p2);
- }
- else if (p2->lnum > 1)
- {
- p2->lnum--;
- p2->col = ml_get_len(p2->lnum);
- if (p2->col > 0)
- {
- p2->col--;
-
- mb_adjustpos(curbuf, p2);
- }
- }
- }
- // if fp2 is on NUL (empty line) inclusive becomes false
- if (*ml_get_pos(p2) == NUL && !virtual_op)
+ // When backing up to previous line, inclusive becomes false.
+ *inclusive = !unadjust_for_sel_inner(p2);
+ // If p2 is on NUL (end of line), inclusive becomes false.
+ if (*inclusive && !virtual_op && *ml_get_pos(p2) == NUL)
*inclusive = FALSE;
}
else if (*region_type == MBLOCK)