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>
diff --git a/src/indent.c b/src/indent.c
index 0d6fadb..4ba31d2 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1021,7 +1021,21 @@
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);
}