From c95e64f41f7f6d1bdc95b047ae9b369743c8637b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 20 May 2024 14:00:31 +0200 Subject: patch 9.1.0423: getregionpos() wrong with blockwise mode and multibyte Problem: getregionpos() wrong with blockwise mode and multibyte. Solution: Use textcol and textlen instead of start_vcol and end_vcol. Handle coladd properly (zeertzjq). Also remove unnecessary buflist_findnr() in add_regionpos_range(), as getregionpos() has already switched buffer. closes: #14805 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- src/ops.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/ops.c') diff --git a/src/ops.c b/src/ops.c index cdc30806ce..605a66494a 100644 --- a/src/ops.c +++ b/src/ops.c @@ -2451,6 +2451,7 @@ charwise_block_prep( p = ml_get(lnum); bdp->startspaces = 0; bdp->endspaces = 0; + bdp->start_char_vcols = 0; if (lnum == start.lnum) { @@ -2462,8 +2463,8 @@ charwise_block_prep( { // Part of a tab selected -- but don't // double-count it. - bdp->startspaces = (ce - cs + 1) - - start.coladd; + bdp->start_char_vcols = ce - cs + 1; + bdp->startspaces = bdp->start_char_vcols - start.coladd; if (bdp->startspaces < 0) bdp->startspaces = 0; startcol++; @@ -2483,19 +2484,16 @@ charwise_block_prep( // of multi-byte char. && (*mb_head_off)(p, p + endcol) == 0)) { - if (start.lnum == end.lnum - && start.col == end.col) + if (start.lnum == end.lnum && start.col == end.col) { // Special case: inside a single char is_oneChar = TRUE; - bdp->startspaces = end.coladd - - start.coladd + inclusive; + bdp->startspaces = end.coladd - start.coladd + inclusive; endcol = startcol; } else { - bdp->endspaces = end.coladd - + inclusive; + bdp->endspaces = end.coladd + inclusive; endcol -= inclusive; } } @@ -2507,6 +2505,7 @@ charwise_block_prep( bdp->textlen = 0; else bdp->textlen = endcol - startcol + inclusive; + bdp->textcol = startcol; bdp->textstart = p + startcol; } -- cgit v1.2.3