patch 9.1.0720: Wrong breakindentopt=list:-1 with multibyte or TABs

Problem:  Wrong breakindentopt=list:-1 with multibyte chars or TABs in
          text matched by 'formatlistpat' (John M Devin)
Solution: Use the width of the match text (zeertzjq)

fixes: #15634
closes: #15635

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-09-07 11:23:54 +02:00
committed by Christian Brabandt
parent 66f65a46c5
commit 61a6ac4d00
6 changed files with 83 additions and 11 deletions

View File

@ -1021,7 +1021,21 @@ get_breakindent_win(
if (wp->w_briopt_list > 0)
prev_list = wp->w_briopt_list;
else
prev_indent = (*regmatch.endp - *regmatch.startp);
{
char_u *ptr = *regmatch.startp;
char_u *end_ptr = *regmatch.endp;
int indent = 0;
// Compute the width of the matched text.
// Use win_chartabsize() so that TAB size is correct,
// while wrapping is ignored.
while (ptr < end_ptr)
{
indent += win_chartabsize(wp, ptr, indent);
MB_PTR_ADV(ptr);
}
prev_indent = indent;
}
}
vim_regfree(regmatch.regprog);
}