diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-05-20 14:00:31 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-05-20 14:00:31 +0200 |
commit | c95e64f41f7f6d1bdc95b047ae9b369743c8637b (patch) | |
tree | 1d65603d5a4dee278f40c0c241057c113885578b /src/ops.c | |
parent | 22029edb6c7b2cb146668354daad60bfe59eaac1 (diff) |
patch 9.1.0423: getregionpos() wrong with blockwise mode and multibytev9.1.0423
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 <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/ops.c')
-rw-r--r-- | src/ops.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -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; } |