From fd1dbb103bb78f04dd15b50f529bb12d922e98eb Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 10 Sep 2021 13:27:41 +0100 Subject: vim-patch:8.1.2281: 'showbreak' cannot be set for one window Problem: 'showbreak' cannot be set for one window. Solution: Make 'showbreak' global-local. https://github.com/vim/vim/commit/ee85702c10495041791f728e977b86005c4496e8 Change in oneleft() is N/A as the relevant condition was removed (has_mbyte is always true for Nvim, so the condition was always false; see commit 73dc9e9). Use wp over curwin for curs_columns(). Required for v8.2.2903 (otherwise test fails as it'll leave the global option set). N/A patches for version.c: vim-patch:8.1.2283: missed on use of p_sbr Problem: Missed on use of p_sbr. Solution: Add missing p_sbr change. https://github.com/vim/vim/commit/91e22eb6e09ec384496fccde812072033fd9e616 Already ported in commit 43a874a. --- src/nvim/screen.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/nvim/screen.c') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index cc0f0feef7..2fea20de55 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2850,7 +2850,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc } if (wp->w_briopt_sbr && draw_state == WL_BRI - 1 - && n_extra == 0 && *p_sbr != NUL) { + && n_extra == 0 && *get_showbreak_value(wp) != NUL) { // draw indent after showbreak value draw_state = WL_BRI; } else if (wp->w_briopt_sbr && draw_state == WL_SBR && n_extra == 0) { @@ -2909,19 +2909,20 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc } char_attr = win_hl_attr(wp, HLF_DED); } - if (*p_sbr != NUL && need_showbreak) { + char_u *const sbr = get_showbreak_value(wp); + if (*sbr != NUL && need_showbreak) { // Draw 'showbreak' at the start of each broken line. - p_extra = p_sbr; + p_extra = sbr; c_extra = NUL; c_final = NUL; - n_extra = (int)STRLEN(p_sbr); + n_extra = (int)STRLEN(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. */ + vcol_sbr = vcol + MB_CHARLEN(sbr); + // Correct end of highlighted area for 'showbreak', + // required when 'linebreak' is also set. if (tocol == vcol) { tocol += n_extra; } @@ -3619,10 +3620,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc if (c == TAB && (!wp->w_p_list || wp->w_p_lcs_chars.tab1)) { int tab_len = 0; long vcol_adjusted = vcol; // removed showbreak length + char_u *const sbr = get_showbreak_value(wp); + // Only adjust the tab_len, when at the first column after the // showbreak value was drawn. - if (*p_sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap) { - vcol_adjusted = vcol - MB_CHARLEN(p_sbr); + if (*sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap) { + vcol_adjusted = vcol - MB_CHARLEN(sbr); } // tab amount depends on current column tab_len = tabstop_padding(vcol_adjusted, -- cgit From b91609a70d6b7be2f067cefc178c9bb749c33b07 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 10 Sep 2021 13:14:50 +0100 Subject: vim-patch:8.2.2903: cursor position wrong on wrapped line with 'signcolumn' Problem: Cursor position wrong on wrapped line with 'signcolumn'. Solution: Don't add space for showbreak twice. (Christian Brabandt, closes vim/vim#8262) https://github.com/vim/vim/commit/a06e345af5b8261c072c95b0446e67cfda439848 Add a modeline to test_display.vim. This introduced a regression fixed by v8.2.3391. --- src/nvim/screen.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/screen.c') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2fea20de55..a9d362538a 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -3554,6 +3554,13 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc char_u *p = ptr - (mb_off + 1); // TODO: is passing p for start of the line OK? n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol, NULL) - 1; + + // We have just drawn the showbreak value, no need to add + // space for it again + if (vcol == vcol_sbr) { + n_extra -= MB_CHARLEN(get_showbreak_value(wp)); + } + if (c == TAB && n_extra + col > grid->Columns) { n_extra = tabstop_padding(vcol, wp->w_buffer->b_p_ts, wp->w_buffer->b_p_vts_array) - 1; -- cgit From 6e1c03bd2dff3bf576f8cee781deee6f986c7f0a Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 10 Sep 2021 15:12:45 +0100 Subject: vim-patch:8.2.3391: crash with combination of 'linebreak' and other options Problem: Crash with combination of 'linebreak' and other options. Solution: Avoid n_extra to become negative. (Christian Brabandt, closes vim/vim#8817) https://github.com/vim/vim/commit/20e0c3d27bda770542c1c0e4c81fd6443c12f3a6 --- src/nvim/screen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim/screen.c') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index a9d362538a..d264557912 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -3556,9 +3556,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol, NULL) - 1; // We have just drawn the showbreak value, no need to add - // space for it again + // space for it again. if (vcol == vcol_sbr) { n_extra -= MB_CHARLEN(get_showbreak_value(wp)); + if (n_extra < 0) { + n_extra = 0; + } } if (c == TAB && n_extra + col > grid->Columns) { -- cgit