patch 9.1.0446: getregionpos() inconsistent for partly-selected multibyte char
Problem: getregionpos() behaves inconsistently for a partly-selected
multibyte char.
Solution: Always use column of the first byte for a partly-selected
multibyte char (zeertzjq).
closes: #14851
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 b389085..d53dda4 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -5788,6 +5788,7 @@
for (lnum = p1.lnum; lnum <= p2.lnum; lnum++)
{
pos_T ret_p1, ret_p2;
+ char_u *line = ml_get(lnum);
colnr_T line_len = ml_get_len(lnum);
if (region_type == MLINE)
@@ -5810,7 +5811,7 @@
{
if (region_type == MBLOCK)
{
- ret_p1.col = bd.textcol;
+ ret_p1.col = mb_prevptr(line, bd.textstart) - line + 1;
ret_p1.coladd = bd.start_char_vcols
- (bd.start_vcol - oa.start_vcol);
}
@@ -5829,7 +5830,7 @@
}
else if (bd.startspaces > 0)
{
- ret_p1.col = bd.textcol;
+ ret_p1.col = mb_prevptr(line, bd.textstart) - line + 1;
ret_p1.coladd = bd.start_char_vcols - bd.startspaces;
}
else