aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/funcs.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-23 14:23:09 +0800
committerGitHub <noreply@github.com>2024-05-23 14:23:09 +0800
commitbdf15dbe6909b39e5d3cf22ae844ebd37862a1a8 (patch)
tree4b885d031e34866f6f401683b33d9e04241e0d56 /src/nvim/eval/funcs.c
parentcd48b72b60af0a8b5a7770ab599e4062e974183d (diff)
downloadrneovim-bdf15dbe6909b39e5d3cf22ae844ebd37862a1a8.tar.gz
rneovim-bdf15dbe6909b39e5d3cf22ae844ebd37862a1a8.tar.bz2
rneovim-bdf15dbe6909b39e5d3cf22ae844ebd37862a1a8.zip
vim-patch:9.1.0433: Wrong yanking with exclusive selection and ve=all (#28933)
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: vim/vim#14830 https://github.com/vim/vim/commit/701ad50a9efcf0adfe6d787b606c4e4dbd31f26d
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r--src/nvim/eval/funcs.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 7453bbb601..fcc86bb708 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -2913,24 +2913,13 @@ static int getregionpos(typval_T *argvars, typval_T *rettv, pos_T *p1, pos_T *p2
}
if (*region_type == kMTCharWise) {
- // handle 'selection' == "exclusive"
+ // Handle 'selection' == "exclusive".
if (is_select_exclusive && !equalpos(*p1, *p2)) {
- if (p2->coladd > 0) {
- p2->coladd--;
- } else if (p2->col > 0) {
- p2->col--;
- mark_mb_adjustpos(curbuf, p2);
- } else if (p2->lnum > 1) {
- p2->lnum--;
- p2->col = ml_get_len(p2->lnum);
- if (p2->col > 0) {
- p2->col--;
- mark_mb_adjustpos(curbuf, p2);
- }
- }
+ // When backing up to previous line, inclusive becomes false.
+ *inclusive = !unadjust_for_sel_inner(p2);
}
- // if fp2 is on NUL (empty line) inclusive becomes false
- if (*ml_get_pos(p2) == NUL && !virtual_op) {
+ // 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 == kMTBlockWise) {