mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.4882: cannot make 'breakindent' use a specific column
Problem: Cannot make 'breakindent' use a specific column. Solution: Add the "column" entry in 'breakindentopt'. (Christian Brabandt, closes #10362, closes #10325)
This commit is contained in:
committed by
Bram Moolenaar
parent
509142ab7a
commit
e7d6dbc572
@@ -1392,14 +1392,20 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
characters. It permits dynamic French paragraph
|
characters. It permits dynamic French paragraph
|
||||||
indentation (negative) or emphasizing the line
|
indentation (negative) or emphasizing the line
|
||||||
continuation (positive).
|
continuation (positive).
|
||||||
|
(default: 0)
|
||||||
sbr Display the 'showbreak' value before applying the
|
sbr Display the 'showbreak' value before applying the
|
||||||
additional indent.
|
additional indent.
|
||||||
|
(default: off)
|
||||||
list:{n} Adds an additional indent for lines that match a
|
list:{n} Adds an additional indent for lines that match a
|
||||||
numbered or bulleted list (using the
|
numbered or bulleted list (using the
|
||||||
'formatlistpat' setting).
|
'formatlistpat' setting).
|
||||||
list:-1 Uses the length of a match with 'formatlistpat'
|
list:-1 Uses the length of a match with 'formatlistpat'
|
||||||
for indentation.
|
for indentation.
|
||||||
The default value for min is 20, shift and list is 0.
|
(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'*
|
||||||
'browsedir' 'bsdir' string (default: "last")
|
'browsedir' 'bsdir' string (default: "last")
|
||||||
|
24
src/indent.c
24
src/indent.c
@@ -866,6 +866,7 @@ briopt_check(win_T *wp)
|
|||||||
long bri_min = 20;
|
long bri_min = 20;
|
||||||
int bri_sbr = FALSE;
|
int bri_sbr = FALSE;
|
||||||
int bri_list = 0;
|
int bri_list = 0;
|
||||||
|
int bri_vcol = 0;
|
||||||
|
|
||||||
p = wp->w_p_briopt;
|
p = wp->w_p_briopt;
|
||||||
while (*p != NUL)
|
while (*p != NUL)
|
||||||
@@ -891,6 +892,11 @@ briopt_check(win_T *wp)
|
|||||||
p += 5;
|
p += 5;
|
||||||
bri_list = getdigits(&p);
|
bri_list = getdigits(&p);
|
||||||
}
|
}
|
||||||
|
else if (STRNCMP(p, "column:", 7) == 0)
|
||||||
|
{
|
||||||
|
p += 7;
|
||||||
|
bri_vcol = getdigits(&p);
|
||||||
|
}
|
||||||
if (*p != ',' && *p != NUL)
|
if (*p != ',' && *p != NUL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
if (*p == ',')
|
if (*p == ',')
|
||||||
@@ -901,6 +907,7 @@ briopt_check(win_T *wp)
|
|||||||
wp->w_briopt_min = bri_min;
|
wp->w_briopt_min = bri_min;
|
||||||
wp->w_briopt_sbr = bri_sbr;
|
wp->w_briopt_sbr = bri_sbr;
|
||||||
wp->w_briopt_list = bri_list;
|
wp->w_briopt_list = bri_list;
|
||||||
|
wp->w_briopt_vcol = bri_vcol;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -953,11 +960,13 @@ get_breakindent_win(
|
|||||||
prev_tick = CHANGEDTICK(wp->w_buffer);
|
prev_tick = CHANGEDTICK(wp->w_buffer);
|
||||||
# ifdef FEAT_VARTABS
|
# ifdef FEAT_VARTABS
|
||||||
prev_vts = wp->w_buffer->b_p_vts_array;
|
prev_vts = wp->w_buffer->b_p_vts_array;
|
||||||
prev_indent = get_indent_str_vtab(line,
|
if (wp->w_briopt_vcol == 0)
|
||||||
|
prev_indent = get_indent_str_vtab(line,
|
||||||
(int)wp->w_buffer->b_p_ts,
|
(int)wp->w_buffer->b_p_ts,
|
||||||
wp->w_buffer->b_p_vts_array, wp->w_p_list);
|
wp->w_buffer->b_p_vts_array, wp->w_p_list);
|
||||||
# else
|
# else
|
||||||
prev_indent = get_indent_str(line,
|
if (wp->w_briopt_vcol == 0)
|
||||||
|
prev_indent = get_indent_str(line,
|
||||||
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
|
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
|
||||||
# endif
|
# endif
|
||||||
prev_listopt = wp->w_briopt_list;
|
prev_listopt = wp->w_briopt_list;
|
||||||
@@ -965,7 +974,7 @@ get_breakindent_win(
|
|||||||
vim_free(prev_flp);
|
vim_free(prev_flp);
|
||||||
prev_flp = vim_strsave(get_flp_value(wp->w_buffer));
|
prev_flp = vim_strsave(get_flp_value(wp->w_buffer));
|
||||||
// add additional indent for numbered lists
|
// add additional indent for numbered lists
|
||||||
if (wp->w_briopt_list != 0)
|
if (wp->w_briopt_list != 0 && wp->w_briopt_vcol == 0)
|
||||||
{
|
{
|
||||||
regmatch_T regmatch;
|
regmatch_T regmatch;
|
||||||
|
|
||||||
@@ -986,7 +995,14 @@ get_breakindent_win(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bri = prev_indent + wp->w_briopt_shift;
|
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'
|
// Add offset for number column, if 'n' is in 'cpoptions'
|
||||||
bri += win_col_off2(wp);
|
bri += win_col_off2(wp);
|
||||||
|
@@ -3215,7 +3215,7 @@ struct diffblock_S
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SNAP_HELP_IDX 0
|
#define SNAP_HELP_IDX 0
|
||||||
#define SNAP_AUCMD_IDX 1
|
#define SNAP_AUCMD_IDX 1
|
||||||
#define SNAP_COUNT 2
|
#define SNAP_COUNT 2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3312,7 +3312,8 @@ struct frame_S
|
|||||||
// for first
|
// for first
|
||||||
// fr_child and fr_win are mutually exclusive
|
// fr_child and fr_win are mutually exclusive
|
||||||
frame_T *fr_child; // first contained frame
|
frame_T *fr_child; // first contained frame
|
||||||
win_T *fr_win; // window that fills this 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
|
#define FR_LEAF 0 // frame is a leaf
|
||||||
@@ -3742,6 +3743,7 @@ struct window_S
|
|||||||
int w_briopt_shift; // additional shift for breakindent
|
int w_briopt_shift; // additional shift for breakindent
|
||||||
int w_briopt_sbr; // sbr in 'briopt'
|
int w_briopt_sbr; // sbr in 'briopt'
|
||||||
int w_briopt_list; // additional indent for lists
|
int w_briopt_list; // additional indent for lists
|
||||||
|
int w_briopt_vcol; // indent for specific column
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
long w_scbind_pos;
|
long w_scbind_pos;
|
||||||
|
@@ -837,16 +837,17 @@ endfunc
|
|||||||
func Test_window_resize_with_linebreak()
|
func Test_window_resize_with_linebreak()
|
||||||
new
|
new
|
||||||
53vnew
|
53vnew
|
||||||
set linebreak
|
setl linebreak
|
||||||
set showbreak=>>
|
setl showbreak=>>
|
||||||
set breakindent
|
setl breakindent
|
||||||
set breakindentopt=shift:4
|
setl breakindentopt=shift:4
|
||||||
call setline(1, "\naaaaaaaaa\n\na\naaaaa\n¯aaaaaaaaaa\naaaaaaaaaaaa\naaa\n\"a:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaa\"\naaaaaaaa\n\"a")
|
call setline(1, "\naaaaaaaaa\n\na\naaaaa\n¯aaaaaaaaaa\naaaaaaaaaaaa\naaa\n\"a:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - aaaaaaaa\"\naaaaaaaa\n\"a")
|
||||||
redraw!
|
redraw!
|
||||||
call assert_equal([" >>aa^@\"a: "], ScreenLines(2, 14))
|
call assert_equal([" >>aa^@\"a: "], ScreenLines(2, 14))
|
||||||
vertical resize 52
|
vertical resize 52
|
||||||
redraw!
|
redraw!
|
||||||
call assert_equal([" >>aaa^@\"a:"], ScreenLines(2, 14))
|
call assert_equal([" >>aaa^@\"a:"], ScreenLines(2, 14))
|
||||||
|
set linebreak& showbreak& breakindent& breakindentopt&
|
||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -943,4 +944,57 @@ func Test_no_extra_indent()
|
|||||||
bwipeout!
|
bwipeout!
|
||||||
endfunc
|
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: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
4882,
|
||||||
/**/
|
/**/
|
||||||
4881,
|
4881,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user