mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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 <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
22029edb6c
commit
c95e64f41f
15
src/ops.c
15
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user