mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
71ee46accf
commit
376fa27237
@ -2243,7 +2243,7 @@ win_line (
|
|||||||
int change_start = MAXCOL; // first col of changed area
|
int change_start = MAXCOL; // first col of changed area
|
||||||
int change_end = -1; // last col of changed area
|
int change_end = -1; // last col of changed area
|
||||||
colnr_T trailcol = MAXCOL; // start of trailing spaces
|
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 = 0; // attribute for the whole line
|
||||||
int line_attr_lowprio = 0; // low-priority attribute for the line
|
int line_attr_lowprio = 0; // low-priority attribute for the line
|
||||||
matchitem_T *cur; // points to the match list
|
matchitem_T *cur; // points to the match list
|
||||||
@ -2654,11 +2654,12 @@ win_line (
|
|||||||
else if (fromcol >= 0 && fromcol < vcol)
|
else if (fromcol >= 0 && fromcol < vcol)
|
||||||
fromcol = vcol;
|
fromcol = vcol;
|
||||||
|
|
||||||
/* When w_skipcol is non-zero, first line needs 'showbreak' */
|
// When w_skipcol is non-zero, first line needs 'showbreak'
|
||||||
if (wp->w_p_wrap)
|
if (wp->w_p_wrap) {
|
||||||
need_showbreak = TRUE;
|
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 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) {
|
if (has_spell) {
|
||||||
size_t len;
|
size_t len;
|
||||||
colnr_T linecol = (colnr_T)(ptr - line);
|
colnr_T linecol = (colnr_T)(ptr - line);
|
||||||
@ -2975,11 +2976,16 @@ win_line (
|
|||||||
}
|
}
|
||||||
p_extra = NULL;
|
p_extra = NULL;
|
||||||
c_extra = ' ';
|
c_extra = ' ';
|
||||||
n_extra = get_breakindent_win(wp, ml_get_buf(wp->w_buffer, lnum, FALSE));
|
n_extra =
|
||||||
/* Correct end of highlighted area for 'breakindent',
|
get_breakindent_win(wp, ml_get_buf(wp->w_buffer, lnum, false));
|
||||||
required wen 'linebreak' is also set. */
|
if (wp->w_skipcol > 0 && wp->w_p_wrap) {
|
||||||
if (tocol == vcol)
|
need_showbreak = false;
|
||||||
|
}
|
||||||
|
// Correct end of highlighted area for 'breakindent',
|
||||||
|
// required wen 'linebreak' is also set.
|
||||||
|
if (tocol == vcol) {
|
||||||
tocol += n_extra;
|
tocol += n_extra;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3008,7 +3014,9 @@ win_line (
|
|||||||
c_final = NUL;
|
c_final = NUL;
|
||||||
n_extra = (int)STRLEN(p_sbr);
|
n_extra = (int)STRLEN(p_sbr);
|
||||||
char_attr = win_hl_attr(wp, HLF_AT);
|
char_attr = win_hl_attr(wp, HLF_AT);
|
||||||
need_showbreak = false;
|
if (wp->w_skipcol == 0 || !wp->w_p_wrap) {
|
||||||
|
need_showbreak = false;
|
||||||
|
}
|
||||||
vcol_sbr = vcol + MB_CHARLEN(p_sbr);
|
vcol_sbr = vcol + MB_CHARLEN(p_sbr);
|
||||||
/* Correct end of highlighted area for 'showbreak',
|
/* Correct end of highlighted area for 'showbreak',
|
||||||
* required when 'linebreak' is also set. */
|
* required when 'linebreak' is also set. */
|
||||||
|
@ -296,3 +296,30 @@ function Test_breakindent16()
|
|||||||
call s:compare_lines(expect, lines)
|
call s:compare_lines(expect, lines)
|
||||||
call s:close_windows()
|
call s:close_windows()
|
||||||
endfunction
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user