vim-patch:8.2.0146: wrong indent when 'showbreak' and 'breakindent' are set

Problem:    Wrong indent when 'showbreak' and 'breakindent' are set and
            'briopt' includes "sbr".
Solution:   Reset "need_showbreak" where needed. (Ken Takata, closes vim/vim#5523)
dfede9a70b
This commit is contained in:
Jan Edmund Lazo 2020-01-23 19:11:32 -05:00
parent 71ee46accf
commit 376fa27237
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 46 additions and 11 deletions

View File

@ -2243,7 +2243,7 @@ win_line (
int change_start = MAXCOL; // first col of changed area
int change_end = -1; // last col of changed area
colnr_T trailcol = MAXCOL; // start of trailing spaces
int need_showbreak = false; // overlong line, skip first x chars
bool need_showbreak = false; // overlong line, skip first x chars
int line_attr = 0; // attribute for the whole line
int line_attr_lowprio = 0; // low-priority attribute for the line
matchitem_T *cur; // points to the match list
@ -2654,11 +2654,12 @@ win_line (
else if (fromcol >= 0 && fromcol < vcol)
fromcol = vcol;
/* When w_skipcol is non-zero, first line needs 'showbreak' */
if (wp->w_p_wrap)
need_showbreak = TRUE;
/* When spell checking a word we need to figure out the start of the
* word and if it's badly spelled or not. */
// When w_skipcol is non-zero, first line needs 'showbreak'
if (wp->w_p_wrap) {
need_showbreak = true;
}
// When spell checking a word we need to figure out the start of the
// word and if it's badly spelled or not.
if (has_spell) {
size_t len;
colnr_T linecol = (colnr_T)(ptr - line);
@ -2975,13 +2976,18 @@ win_line (
}
p_extra = NULL;
c_extra = ' ';
n_extra = get_breakindent_win(wp, ml_get_buf(wp->w_buffer, lnum, FALSE));
/* Correct end of highlighted area for 'breakindent',
required wen 'linebreak' is also set. */
if (tocol == vcol)
n_extra =
get_breakindent_win(wp, ml_get_buf(wp->w_buffer, lnum, false));
if (wp->w_skipcol > 0 && wp->w_p_wrap) {
need_showbreak = false;
}
// Correct end of highlighted area for 'breakindent',
// required wen 'linebreak' is also set.
if (tocol == vcol) {
tocol += n_extra;
}
}
}
if (draw_state == WL_SBR - 1 && n_extra == 0) {
draw_state = WL_SBR;
@ -3008,7 +3014,9 @@ win_line (
c_final = NUL;
n_extra = (int)STRLEN(p_sbr);
char_attr = win_hl_attr(wp, HLF_AT);
if (wp->w_skipcol == 0 || !wp->w_p_wrap) {
need_showbreak = false;
}
vcol_sbr = vcol + MB_CHARLEN(p_sbr);
/* Correct end of highlighted area for 'showbreak',
* required when 'linebreak' is also set. */

View File

@ -296,3 +296,30 @@ function Test_breakindent16()
call s:compare_lines(expect, lines)
call s:close_windows()
endfunction
func Test_breakindent19_sbr_nextpage()
let s:input = ""
call s:test_windows('setl breakindent briopt=shift:2,sbr,min:18 sbr=>')
call setline(1, repeat('a', 200))
norm! 1gg
redraw!
let lines = s:screen_lines(1, 20)
let expect = [
\ "aaaaaaaaaaaaaaaaaaaa",
\ "> aaaaaaaaaaaaaaaaaa",
\ "> aaaaaaaaaaaaaaaaaa",
\ ]
call s:compare_lines(expect, lines)
" Scroll down one screen line
setl scrolloff=5
norm! 5gj
redraw!
let lines = s:screen_lines(1, 20)
let expect = [
\ "> aaaaaaaaaaaaaaaaaa",
\ "> aaaaaaaaaaaaaaaaaa",
\ "> aaaaaaaaaaaaaaaaaa",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows('set breakindent& briopt& sbr&')
endfunc