diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-05-23 07:47:55 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-05-23 07:47:55 +0200 |
commit | 701ad50a9efcf0adfe6d787b606c4e4dbd31f26d (patch) | |
tree | a9f93efb26cf90fe4ea9cbb79d1059d07bd345b2 /src/evalfunc.c | |
parent | f2d74e3b63e8ba4ed620ae41119929b327c7cfbf (diff) |
patch 9.1.0433: Wrong yanking with exclusive selection and ve=allv9.1.0433
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>
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index b65df5dd90..f70b032ad2 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5594,31 +5594,12 @@ getregionpos( 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) |