forked from aniani/vim
patch 9.0.0358: 'breakindent' does not indent non-lists
Problem: 'breakindent' does not indent non-lists with "breakindentopt=list:-1". Solution: Adjust indent computation. (Maxim Kim, closes #11038)
This commit is contained in:
committed by
Bram Moolenaar
parent
cf2bb63397
commit
119167265e
11
src/indent.c
11
src/indent.c
@@ -998,7 +998,7 @@ get_breakindent_win(
|
|||||||
if (wp->w_briopt_list > 0)
|
if (wp->w_briopt_list > 0)
|
||||||
prev_list = wp->w_briopt_list;
|
prev_list = wp->w_briopt_list;
|
||||||
else
|
else
|
||||||
prev_list = (*regmatch.endp - *regmatch.startp);
|
prev_indent = (*regmatch.endp - *regmatch.startp);
|
||||||
}
|
}
|
||||||
vim_regfree(regmatch.regprog);
|
vim_regfree(regmatch.regprog);
|
||||||
}
|
}
|
||||||
@@ -1017,13 +1017,8 @@ get_breakindent_win(
|
|||||||
bri += win_col_off2(wp);
|
bri += win_col_off2(wp);
|
||||||
|
|
||||||
// add additional indent for numbered lists
|
// add additional indent for numbered lists
|
||||||
if (wp->w_briopt_list != 0)
|
if (wp->w_briopt_list > 0)
|
||||||
{
|
bri += prev_list;
|
||||||
if (wp->w_briopt_list > 0)
|
|
||||||
bri += prev_list;
|
|
||||||
else
|
|
||||||
bri = prev_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
// indent minus the length of the showbreak string
|
// indent minus the length of the showbreak string
|
||||||
if (wp->w_briopt_sbr)
|
if (wp->w_briopt_sbr)
|
||||||
|
@@ -818,7 +818,7 @@ func Test_breakindent20_list()
|
|||||||
|
|
||||||
" check formatlistpat indent with different list level
|
" check formatlistpat indent with different list level
|
||||||
" showbreak and sbr
|
" showbreak and sbr
|
||||||
setl briopt=min:5,sbr,list:-1,shift:2
|
setl briopt=min:5,sbr,list:-1
|
||||||
setl showbreak=>
|
setl showbreak=>
|
||||||
redraw!
|
redraw!
|
||||||
let expect = [
|
let expect = [
|
||||||
@@ -831,6 +831,44 @@ func Test_breakindent20_list()
|
|||||||
\ ]
|
\ ]
|
||||||
let lines = s:screen_lines2(1, 6, 20)
|
let lines = s:screen_lines2(1, 6, 20)
|
||||||
call s:compare_lines(expect, lines)
|
call s:compare_lines(expect, lines)
|
||||||
|
|
||||||
|
" check formatlistpat indent with different list level
|
||||||
|
" showbreak sbr and shift
|
||||||
|
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)
|
||||||
|
|
||||||
|
" check breakindent works if breakindentopt=list:-1
|
||||||
|
" for a non list content
|
||||||
|
%delete _
|
||||||
|
call setline(1, [' Congress shall make no law',
|
||||||
|
\ ' Congress shall make no law',
|
||||||
|
\ ' Congress shall make no law'])
|
||||||
|
norm! 1gg
|
||||||
|
setl briopt=min:5,list:-1
|
||||||
|
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&')
|
call s:close_windows('set breakindent& briopt& linebreak& list& listchars& showbreak&')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -707,6 +707,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
358,
|
||||||
/**/
|
/**/
|
||||||
357,
|
357,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user