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/testdir/test_breakindent.vim b/src/testdir/test_breakindent.vim
index b306c02..16a11b3 100644
--- a/src/testdir/test_breakindent.vim
+++ b/src/testdir/test_breakindent.vim
@@ -797,18 +797,73 @@
\ ]
let lines = s:screen_lines2(1, 9, 20)
call s:compare_lines(expect, lines)
+
+ " check with TABs
+ call setline(1, ["\t1.\tCongress shall make no law",
+ \ "\t2.) Congress shall make no law",
+ \ "\t3.] Congress shall make no law"])
+ setl tabstop=4 list listchars=tab:<->
+ norm! 1gg
+ redraw!
+ let expect = [
+ \ "<-->1.<>Congress ",
+ \ " shall make ",
+ \ " no law ",
+ \ "<-->2.) Congress ",
+ \ " shall make ",
+ \ " no law ",
+ \ "<-->3.] Congress ",
+ \ " shall make ",
+ \ " no law ",
+ \ ]
+ let lines = s:screen_lines2(1, 9, 20)
+ call s:compare_lines(expect, lines)
+
+ setl tabstop=2 nolist
+ redraw!
+ let expect = [
+ \ " 1. Congress ",
+ \ " shall make no ",
+ \ " law ",
+ \ " 2.) Congress ",
+ \ " shall make no ",
+ \ " law ",
+ \ " 3.] Congress ",
+ \ " shall make no ",
+ \ " law ",
+ \ ]
+ let lines = s:screen_lines2(1, 9, 20)
+ call s:compare_lines(expect, lines)
+
+ setl tabstop& list listchars=space:_
+ redraw!
+ let expect = [
+ \ "^I1.^ICongress_ ",
+ \ " shall_make_no_",
+ \ " law ",
+ \ "^I2.)_Congress_ ",
+ \ " shall_make_no_",
+ \ " law ",
+ \ "^I3.]_Congress_ ",
+ \ " shall_make_no_",
+ \ " law ",
+ \ ]
+ let lines = s:screen_lines2(1, 9, 20)
+ call s:compare_lines(expect, lines)
+
" check formatlistpat indent with different list levels
- let &l:flp = '^\s*\*\+\s\+'
+ let &l:flp = '^\s*\(\*\|•\)\+\s\+'
+ setl list&vim listchars&vim
%delete _
call setline(1, ['* Congress shall make no law',
- \ '*** Congress shall make no law',
+ \ '••• Congress shall make no law',
\ '**** Congress shall make no law'])
norm! 1gg
redraw!
let expect = [
\ "* Congress shall ",
\ " make no law ",
- \ "*** Congress shall ",
+ \ "••• Congress shall ",
\ " make no law ",
\ "**** Congress shall ",
\ " make no law ",
@@ -824,7 +879,7 @@
let expect = [
\ "* Congress shall ",
\ "> make no law ",
- \ "*** Congress shall ",
+ \ "••• Congress shall ",
\ "> make no law ",
\ "**** Congress shall ",
\ "> make no law ",
@@ -840,7 +895,7 @@
let expect = [
\ "* Congress shall ",
\ "> make no law ",
- \ "*** Congress shall ",
+ \ "••• Congress shall ",
\ "> make no law ",
\ "**** Congress shall ",
\ "> make no law ",