To: vim_dev@googlegroups.com Subject: Patch 8.2.3198 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3198 Problem: Cannot use 'formatlistpat' for breakindent. Solution: Use a negative list indent. (Maxim Kim, closes #8594) Files: runtime/doc/options.txt, src/indent.c, src/testdir/test_breakindent.vim *** ../vim-8.2.3197/runtime/doc/options.txt 2021-07-14 20:00:24.545690127 +0200 --- runtime/doc/options.txt 2021-07-22 11:29:26.372988449 +0200 *************** *** 1326,1334 **** continuation (positive). sbr Display the 'showbreak' value before applying the additional indent. ! list:{n} Adds an additional indent for lines that match a numbered or bulleted list (using the 'formatlistpat' setting). The default value for min is 20, shift and list is 0. *'browsedir'* *'bsdir'* --- 1326,1336 ---- continuation (positive). sbr Display the 'showbreak' value before applying the additional indent. ! list:{n} Adds an additional indent for lines that match a numbered or bulleted list (using the 'formatlistpat' setting). + list:-1 Uses the length of a match with 'formatlistpat' + for indentation. The default value for min is 20, shift and list is 0. *'browsedir'* *'bsdir'* *** ../vim-8.2.3197/src/indent.c 2021-07-14 20:00:24.545690127 +0200 --- src/indent.c 2021-07-22 11:25:46.613519880 +0200 *************** *** 941,955 **** } bri = prev_indent + wp->w_briopt_shift; - // indent minus the length of the showbreak string - if (wp->w_briopt_sbr) - bri -= vim_strsize(get_showbreak_value(wp)); - // Add offset for number column, if 'n' is in 'cpoptions' bri += win_col_off2(wp); // add additional indent for numbered lists ! if (wp->w_briopt_list > 0) { regmatch_T regmatch; --- 941,951 ---- } bri = prev_indent + wp->w_briopt_shift; // Add offset for number column, if 'n' is in 'cpoptions' bri += win_col_off2(wp); // add additional indent for numbered lists ! if (wp->w_briopt_list != 0) { regmatch_T regmatch; *************** *** 958,968 **** if (regmatch.regprog != NULL) { if (vim_regexec(®match, line, 0)) ! bri += wp->w_briopt_list; vim_regfree(regmatch.regprog); } } // never indent past left window margin if (bri < 0) bri = 0; --- 954,974 ---- if (regmatch.regprog != NULL) { if (vim_regexec(®match, line, 0)) ! { ! if (wp->w_briopt_list > 0) ! bri += wp->w_briopt_list; ! else ! bri = (*regmatch.endp - *regmatch.startp); ! } vim_regfree(regmatch.regprog); } } + // indent minus the length of the showbreak string + if (wp->w_briopt_sbr) + bri -= vim_strsize(get_showbreak_value(wp)); + + // never indent past left window margin if (bri < 0) bri = 0; *** ../vim-8.2.3197/src/testdir/test_breakindent.vim 2021-07-14 20:00:24.545690127 +0200 --- src/testdir/test_breakindent.vim 2021-07-22 11:25:46.613519880 +0200 *************** *** 759,764 **** --- 759,765 ---- \ ] let lines = s:screen_lines2(1, 9, 20) call s:compare_lines(expect, lines) + " reset linebreak option " Note: it indents by one additional " space, because of the leading space. *************** *** 775,781 **** let lines = s:screen_lines2(1, 6, 20) call s:compare_lines(expect, lines) ! call s:close_windows('set breakindent& briopt& linebreak& list& listchars&') endfunc " vim: shiftwidth=2 sts=2 expandtab --- 776,834 ---- let lines = s:screen_lines2(1, 6, 20) call s:compare_lines(expect, lines) ! " check formatlistpat indent ! setl briopt=min:5,list:-1 ! setl linebreak list&vim listchars&vim ! let &l:flp = '^\s*\d\+\.\?[\]:)}\t ]\s*' ! 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) ! " check formatlistpat indent with different list levels ! let &l:flp = '^\s*\*\+\s\+' ! redraw! ! %delete _ ! call setline(1, ['* Congress shall make no law', ! \ '*** Congress shall make no law', ! \ '**** Congress shall make no law']) ! norm! 1gg ! let expect = [ ! \ "* Congress shall ", ! \ " make no law ", ! \ "*** Congress shall ", ! \ " make no law ", ! \ "**** Congress shall ", ! \ " make no law ", ! \ ] ! let lines = s:screen_lines2(1, 6, 20) ! call s:compare_lines(expect, lines) ! ! " check formatlistpat indent with different list level ! " showbreak and sbr ! setl briopt=min:5,sbr,list:-1,shift:2 ! setl showbreak=> ! redraw! ! let expect = [ ! \ "* Congress shall ", ! \ "> make no law ", ! \ "*** Congress shall ", ! \ "> make no law ", ! \ "**** Congress shall ", ! \ "> make no law ", ! \ ] ! let lines = s:screen_lines2(1, 6, 20) ! call s:compare_lines(expect, lines) ! call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&') endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3197/src/version.c 2021-07-21 22:20:30.066401728 +0200 --- src/version.c 2021-07-22 11:27:43.409237984 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3198, /**/ -- hundred-and-one symptoms of being an internet addict: 200. You really believe in the concept of a "paperless" office. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///