Patch 8.2.4882
Problem: Cannot make 'breakindent' use a specific column.
Solution: Add the "column" entry in 'breakindentopt'. (Christian Brabandt,
closes #10362, closes #10325)
Files: runtime/doc/options.txt, src/indent.c, src/structs.h,
src/testdir/test_breakindent.vim
*** ../vim-8.2.4881/runtime/doc/options.txt 2022-04-13 11:47:21.707886568 +0100
--- runtime/doc/options.txt 2022-05-06 12:05:02.409355520 +0100
***************
*** 1388,1406 ****
characters. It permits dynamic French paragraph
indentation (negative) or emphasizing the line
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'*
'browsedir' 'bsdir' string (default: "last")
global
! {only for Motif, Athena, GTK, Mac and Win32 GUI}
Which directory to use for the file browser:
last Use same directory as with last file browser, where a
file was opened or saved.
--- 1392,1416 ----
characters. It permits dynamic French paragraph
indentation (negative) or emphasizing the line
continuation (positive).
+ (default: 0)
sbr Display the 'showbreak' value before applying the
additional indent.
+ (default: off)
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.
! (default: 0)
! column:{n} Indent at column {n}. Will overrule the other
! sub-options. Note: an additional indent may be
! added for the 'showbreak' setting.
! (default: off)
*'browsedir'* *'bsdir'*
'browsedir' 'bsdir' string (default: "last")
global
! {only for Motif, GTK, Mac and Win32 GUI}
Which directory to use for the file browser:
last Use same directory as with last file browser, where a
file was opened or saved.
*** ../vim-8.2.4881/src/indent.c 2022-04-20 10:22:50.146322863 +0100
--- src/indent.c 2022-05-06 12:12:50.552653078 +0100
***************
*** 866,871 ****
--- 866,872 ----
long bri_min = 20;
int bri_sbr = FALSE;
int bri_list = 0;
+ int bri_vcol = 0;
p = wp->w_p_briopt;
while (*p != NUL)
***************
*** 891,896 ****
--- 892,902 ----
p += 5;
bri_list = getdigits(&p);
}
+ else if (STRNCMP(p, "column:", 7) == 0)
+ {
+ p += 7;
+ bri_vcol = getdigits(&p);
+ }
if (*p != ',' && *p != NUL)
return FAIL;
if (*p == ',')
***************
*** 901,906 ****
--- 907,913 ----
wp->w_briopt_min = bri_min;
wp->w_briopt_sbr = bri_sbr;
wp->w_briopt_list = bri_list;
+ wp->w_briopt_vcol = bri_vcol;
return OK;
}
***************
*** 953,963 ****
prev_tick = CHANGEDTICK(wp->w_buffer);
# ifdef FEAT_VARTABS
prev_vts = wp->w_buffer->b_p_vts_array;
! prev_indent = get_indent_str_vtab(line,
(int)wp->w_buffer->b_p_ts,
wp->w_buffer->b_p_vts_array, wp->w_p_list);
# else
! prev_indent = get_indent_str(line,
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
# endif
prev_listopt = wp->w_briopt_list;
--- 960,972 ----
prev_tick = CHANGEDTICK(wp->w_buffer);
# ifdef FEAT_VARTABS
prev_vts = wp->w_buffer->b_p_vts_array;
! if (wp->w_briopt_vcol == 0)
! prev_indent = get_indent_str_vtab(line,
(int)wp->w_buffer->b_p_ts,
wp->w_buffer->b_p_vts_array, wp->w_p_list);
# else
! if (wp->w_briopt_vcol == 0)
! prev_indent = get_indent_str(line,
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
# endif
prev_listopt = wp->w_briopt_list;
***************
*** 965,971 ****
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;
--- 974,980 ----
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 && wp->w_briopt_vcol == 0)
{
regmatch_T regmatch;
***************
*** 986,992 ****
}
}
}
! bri = prev_indent + wp->w_briopt_shift;
// Add offset for number column, if 'n' is in 'cpoptions'
bri += win_col_off2(wp);
--- 995,1008 ----
}
}
}
! if (wp->w_briopt_vcol != 0)
! {
! // column value has priority
! bri = wp->w_briopt_vcol;
! prev_list = 0;
! }
! else
! bri = prev_indent + wp->w_briopt_shift;
// Add offset for number column, if 'n' is in 'cpoptions'
bri += win_col_off2(wp);
*** ../vim-8.2.4881/src/structs.h 2022-04-23 12:05:47.398319460 +0100
--- src/structs.h 2022-05-06 12:05:02.409355520 +0100
***************
*** 3215,3221 ****
#endif
#define SNAP_HELP_IDX 0
! #define SNAP_AUCMD_IDX 1
#define SNAP_COUNT 2
/*
--- 3215,3221 ----
#endif
#define SNAP_HELP_IDX 0
! #define SNAP_AUCMD_IDX 1
#define SNAP_COUNT 2
/*
***************
*** 3312,3318 ****
// for first
// fr_child and fr_win are mutually exclusive
frame_T *fr_child; // first contained frame
! win_T *fr_win; // window that fills this frame
};
#define FR_LEAF 0 // frame is a leaf
--- 3312,3319 ----
// for first
// fr_child and fr_win are mutually exclusive
frame_T *fr_child; // first contained frame
! win_T *fr_win; // window that fills this frame; for a snapshot
! // set to the current window
};
#define FR_LEAF 0 // frame is a leaf
***************
*** 3742,3747 ****
--- 3743,3749 ----
int w_briopt_shift; // additional shift for breakindent
int w_briopt_sbr; // sbr in 'briopt'
int w_briopt_list; // additional indent for lists
+ int w_briopt_vcol; // indent for specific column
#endif
long w_scbind_pos;
*** ../vim-8.2.4881/src/testdir/test_breakindent.vim 2022-03-22 21:14:51.752456009 +0000
--- src/testdir/test_breakindent.vim 2022-05-06 12:05:02.409355520 +0100
***************
*** 837,852 ****
func Test_window_resize_with_linebreak()
new
53vnew
! set linebreak
! set showbreak=>>
! set breakindent
! set breakindentopt=shift:4
call setline(1, "\naaaaaaaaa\n\na\naaaaa\n¯aaaaaaaaaa\naaaaaaaaaaaa\naaa\n\"a:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaa\"\naaaaaaaa\n\"a")
redraw!
call assert_equal([" >>aa^@\"a: "], ScreenLines(2, 14))
vertical resize 52
redraw!
call assert_equal([" >>aaa^@\"a:"], ScreenLines(2, 14))
%bw!
endfunc
--- 837,853 ----
func Test_window_resize_with_linebreak()
new
53vnew
! setl linebreak
! setl showbreak=>>
! setl breakindent
! setl breakindentopt=shift:4
call setline(1, "\naaaaaaaaa\n\na\naaaaa\n¯aaaaaaaaaa\naaaaaaaaaaaa\naaa\n\"a:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaa\"\naaaaaaaa\n\"a")
redraw!
call assert_equal([" >>aa^@\"a: "], ScreenLines(2, 14))
vertical resize 52
redraw!
call assert_equal([" >>aaa^@\"a:"], ScreenLines(2, 14))
+ set linebreak& showbreak& breakindent& breakindentopt&
%bw!
endfunc
***************
*** 942,946 ****
--- 943,1000 ----
call s:compare_lines(expect, lines)
bwipeout!
endfunc
+
+ func Test_breakindent_column()
+ " restore original
+ let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"
+ call s:test_windows('setl breakindent breakindentopt=column:10')
+ redraw!
+ " 1) default: does not indent, too wide :(
+ let expect = [
+ \ " ",
+ \ " abcdefghijklmnop",
+ \ "qrstuvwxyzABCDEFGHIJ",
+ \ "KLMNOP "
+ \ ]
+ let lines = s:screen_lines2(1, 4, 20)
+ call s:compare_lines(expect, lines)
+ " 2) lower min value, so that breakindent works
+ setl breakindentopt+=min:5
+ redraw!
+ let expect = [
+ \ " ",
+ \ " abcdefghijklmnop",
+ \ " qrstuvwxyz",
+ \ " ABCDEFGHIJ",
+ \ " KLMNOP "
+ \ ]
+ let lines = s:screen_lines2(1, 5, 20)
+ " 3) set shift option -> no influence
+ setl breakindentopt+=shift:5
+ redraw!
+ let expect = [
+ \ " ",
+ \ " abcdefghijklmnop",
+ \ " qrstuvwxyz",
+ \ " ABCDEFGHIJ",
+ \ " KLMNOP "
+ \ ]
+ let lines = s:screen_lines2(1, 5, 20)
+ call s:compare_lines(expect, lines)
+ " 4) add showbreak value
+ setl showbreak=++
+ redraw!
+ let expect = [
+ \ " ",
+ \ " abcdefghijklmnop",
+ \ " ++qrstuvwx",
+ \ " ++yzABCDEF",
+ \ " ++GHIJKLMN",
+ \ " ++OP "
+ \ ]
+ let lines = s:screen_lines2(1, 6, 20)
+ call s:compare_lines(expect, lines)
+ bwipeout!
+ endfunc
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.4881/src/version.c 2022-05-06 11:44:03.815966278 +0100
--- src/version.c 2022-05-06 12:07:52.325087696 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4882,
/**/
--
"New York, the city that never sleeps". "There is so much noise?"
/// Bram Moolenaar -- Br...@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 ///