diff options
author | Christian Brabandt <cb@256bit.org> | 2022-01-15 10:01:05 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-15 10:01:05 +0000 |
commit | c53b467473160b5cfce77277fbae414bf43e66ce (patch) | |
tree | 0b9c46f21daf65cd1dde027cbae993bcb7d0608f /src/testdir/test_breakindent.vim | |
parent | ece07639f4989a300276d66b13553c21a7435030 (diff) |
patch 8.2.4093: cached breakindent values not initialized properlyv8.2.4093
Problem: Cached breakindent values not initialized properly.
Solution: Initialize and cache formatlistpat. (Christian Brabandt,
closes #9526, closes #9512)
Diffstat (limited to 'src/testdir/test_breakindent.vim')
-rw-r--r-- | src/testdir/test_breakindent.vim | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/testdir/test_breakindent.vim b/src/testdir/test_breakindent.vim index 0c143b1943..2ac127dd54 100644 --- a/src/testdir/test_breakindent.vim +++ b/src/testdir/test_breakindent.vim @@ -849,4 +849,61 @@ func Test_window_resize_with_linebreak() %bw! endfunc +func Test_no_spurious_match() + let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50)) + call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls') + let @/ = '\%>3v[y]' + redraw! + call searchcount().total->assert_equal(1) + " cleanup + set hls&vim + let s:input = "\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" + bwipeout! +endfunc + +func Test_no_extra_indent() + call s:test_windows('setl breakindent breakindentopt=list:-1,min:10') + %d + let &l:formatlistpat='^\s*\d\+\.\s\+' + let text = 'word ' + let len = text->strcharlen() + let line1 = text->repeat((winwidth(0) / len) * 2) + let line2 = repeat(' ', 2) .. '1. ' .. line1 + call setline(1, [line2]) + redraw! + " 1) matches formatlist pattern, so indent + let expect = [ + \ " 1. word word word ", + \ " word word word ", + \ " word word ", + \ "~ ", + \ ] + let lines = s:screen_lines2(1, 4, 20) + call s:compare_lines(expect, lines) + " 2) change formatlist pattern + " -> indent adjusted + let &l:formatlistpat='^\s*\d\+\.' + let expect = [ + \ " 1. word word word ", + \ " word word word ", + \ " word word ", + \ "~ ", + \ ] + let lines = s:screen_lines2(1, 4, 20) + " 3) add something in front, no additional indent + norm! gg0 + exe ":norm! 5iword \<esc>" + redraw! + let expect = [ + \ "word word word word ", + \ "word 1. word word ", + \ "word word word word ", + \ "word word ", + \ "~ ", + \ ] + let lines = s:screen_lines2(1, 5, 20) + call s:compare_lines(expect, lines) + bwipeout! +endfunc + " vim: shiftwidth=2 sts=2 expandtab |