Patch 8.2.4093
Problem: Cached breakindent values not initialized properly.
Solution: Initialize and cache formatlistpat. (Christian Brabandt,
closes #9526, closes #9512)
Files: runtime/doc/options.txt, src/indent.c, src/option.c,
src/proto/option.pro, src/testdir/test_breakindent.vim
*** ../vim-8.2.4092/runtime/doc/options.txt 2021-12-26 12:07:24.798944010
+0000
--- runtime/doc/options.txt 2022-01-15 09:50:48.197456124 +0000
***************
*** 1370,1375 ****
--- 1370,1376 ----
text should normally be narrower. This prevents
text indented almost to the right window border
occupying lot of vertical space when broken.
+ (default: 20)
shift:{n} After applying 'breakindent', the wrapped line's
beginning will be shifted by the given number of
characters. It permits dynamic French paragraph
*** ../vim-8.2.4092/src/indent.c 2022-01-07 16:55:27.112417600 +0000
--- src/indent.c 2022-01-15 10:00:12.996681829 +0000
***************
*** 924,929 ****
--- 924,931 ----
# endif
static int prev_list = 0; // cached list value
static int prev_listopt = 0; // cached w_p_briopt_list value
+ // cached formatlistpat value
+ static char_u *prev_flp = NULL;
int bri = 0;
// window width minus window margin space, i.e. what rests for text
const int eff_wwidth = wp->w_width
***************
*** 931,940 ****
&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
? number_width(wp) + 1 : 0);
! // used cached indent, unless line, 'tabstop' or briopt_list changed
if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
|| prev_tick != CHANGEDTICK(wp->w_buffer)
|| prev_listopt != wp->w_briopt_list
# ifdef FEAT_VARTABS
|| prev_vts != wp->w_buffer->b_p_vts_array
# endif
--- 933,948 ----
&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
? number_width(wp) + 1 : 0);
! // used cached indent, unless
! // - line pointer changed
! // - 'tabstop' changed
! // - 'briopt_list changed' changed or
! // - 'formatlistpattern' changed
if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
|| prev_tick != CHANGEDTICK(wp->w_buffer)
|| prev_listopt != wp->w_briopt_list
+ || (prev_flp == NULL
+ || (STRCMP(prev_flp, get_flp_value(wp->w_buffer)) != 0))
# ifdef FEAT_VARTABS
|| prev_vts != wp->w_buffer->b_p_vts_array
# endif
***************
*** 953,965 ****
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
# endif
prev_listopt = wp->w_briopt_list;
// add additional indent for numbered lists
if (wp->w_briopt_list != 0)
{
regmatch_T regmatch;
! regmatch.regprog = vim_regcomp(curbuf->b_p_flp,
! RE_MAGIC + RE_STRING + RE_AUTO +
RE_STRICT);
if (regmatch.regprog != NULL)
{
--- 961,976 ----
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
# endif
prev_listopt = wp->w_briopt_list;
+ prev_list = 0;
+ vim_free(prev_flp);
+ prev_flp = vim_strsave(get_flp_value(wp->w_buffer));
// add additional indent for numbered lists
if (wp->w_briopt_list != 0)
{
regmatch_T regmatch;
! regmatch.regprog = vim_regcomp(prev_flp,
! RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT);
if (regmatch.regprog != NULL)
{
*** ../vim-8.2.4092/src/option.c 2022-01-08 12:41:12.208795550 +0000
--- src/option.c 2022-01-15 09:50:48.197456124 +0000
***************
*** 7053,7058 ****
--- 7053,7070 ----
}
/*
+ * Get the local or global value of 'formatlistpat'.
+ */
+ char_u *
+ get_flp_value(buf_T *buf)
+ {
+ return buf->b_p_flp ? buf->b_p_flp : p_flp;
+ if (buf->b_p_flp == NULL || *buf->b_p_flp == NUL)
+ return p_flp;
+ return buf->b_p_flp;
+ }
+
+ /*
* Get the local or global value of the 'virtualedit' flags.
*/
unsigned int
*** ../vim-8.2.4092/src/proto/option.pro 2021-12-06 11:03:50.950900210
+0000
--- src/proto/option.pro 2022-01-15 09:50:48.197456124 +0000
***************
*** 73,78 ****
--- 73,79 ----
long get_scrolloff_value(void);
long get_sidescrolloff_value(void);
unsigned int get_bkc_value(buf_T *buf);
+ char_u *get_flp_value(buf_T *buf);
unsigned int get_ve_flags(void);
char_u *get_showbreak_value(win_T *win);
dict_T *get_winbuf_options(int bufopt);
*** ../vim-8.2.4092/src/testdir/test_breakindent.vim 2021-09-02
19:05:22.925120220 +0100
--- src/testdir/test_breakindent.vim 2022-01-15 09:50:48.197456124 +0000
***************
*** 849,852 ****
--- 849,909 ----
%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
*** ../vim-8.2.4092/src/version.c 2022-01-14 21:28:55.580849073 +0000
--- src/version.c 2022-01-15 09:56:29.829032222 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4093,
/**/
--
PRINCE: He's come to rescue me, father.
LAUNCELOT: (embarrassed) Well, let's not jump to conclusions ...
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220115100137.F0BB91C03C8%40moolenaar.net.