diff --git a/src/drawline.c b/src/drawline.c index 2388193b97..51f2a5379c 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -128,6 +128,8 @@ typedef struct { long vcol_sbr; // virtual column after showbreak int need_showbreak; // overlong line, skipping first x chars int dont_use_showbreak; // do not use 'showbreak' + int lbr_padding; // inserted columns for linebreak + int sbr_padding; #endif #ifdef FEAT_PROP_POPUP int text_prop_above_count; @@ -146,6 +148,7 @@ typedef struct { // with win_attr if needed int n_attr_skip; // chars to skip before using extra_attr int c_extra; // extra chars, all the same + int is_extra; int c_final; // final char, mandatory if set int extra_for_textprop; // n_extra set for textprop int start_extra_for_textprop; // extra_for_textprop was just set @@ -520,6 +523,8 @@ handle_breakindent(win_T *wp, winlinevars_T *wlv) wlv->c_final = NUL; wlv->n_extra = get_breakindent_win(wp, ml_get_buf(wp->w_buffer, wlv->lnum, FALSE)); + wlv->lbr_padding += get_breakindent_win(wp, + ml_get_buf(wp->w_buffer, wlv->lnum, FALSE)); if (wlv->row == wlv->startrow) { wlv->n_extra -= win_col_off2(wp); @@ -583,6 +588,7 @@ handle_showbreak_and_filler(win_T *wp, winlinevars_T *wlv) wlv->c_final = NUL; wlv->n_extra = (int)STRLEN(sbr); wlv->vcol_sbr = wlv->vcol + MB_CHARLEN(sbr); + wlv->sbr_padding += MB_CHARLEN(sbr); // Correct start of highlighted area for 'showbreak'. if (wlv->fromcol >= wlv->vcol && wlv->fromcol < wlv->vcol_sbr) @@ -910,13 +916,14 @@ draw_screen_line(win_T *wp, winlinevars_T *wlv) // edge for 'cursorcolumn'. wlv->col -= wlv->boguscols; wlv->boguscols = 0; -# define VCOL_HLC (wlv->vcol - wlv->vcol_off_co - wlv->vcol_off_tp) +# define VCOL_HLC (wlv->vcol - wlv->vcol_off_co - wlv->vcol_off_tp - wlv->lbr_padding) # else # define VCOL_HLC (wlv->vcol - wlv->vcol_off_tp) # endif if (wlv->draw_color_col) - wlv->draw_color_col = advance_color_col(VCOL_HLC, &wlv->color_cols); + wlv->draw_color_col = + advance_color_col(VCOL_HLC - wlv->sbr_padding, &wlv->color_cols); if (((wp->w_p_cuc && (int)wp->w_virtcol >= VCOL_HLC - wlv->eol_hl_off @@ -959,10 +966,11 @@ draw_screen_line(win_T *wp, winlinevars_T *wlv) if (wlv->line_attr != 0) attr = hl_combine_attr(attr, wlv->line_attr); # endif - if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol + if (wp->w_p_cuc && + VCOL_HLC == (long)wp->w_virtcol - wlv->lbr_padding && wlv->lnum != wp->w_cursor.lnum) attr = hl_combine_attr(attr, HL_ATTR(HLF_CUC)); - else if (wlv->draw_color_col && VCOL_HLC == *wlv->color_cols) + else if (wlv->draw_color_col && VCOL_HLC - wlv->sbr_padding == *wlv->color_cols) attr = hl_combine_attr(attr, HL_ATTR(HLF_MC)); ScreenAttrs[wlv->off] = attr; ScreenCols[wlv->off] = wlv->vcol; @@ -1273,7 +1281,7 @@ win_line( int is_concealing = FALSE; int did_wcol = FALSE; int old_boguscols = 0; -# define VCOL_HLC (wlv.vcol - wlv.vcol_off_co - wlv.vcol_off_tp) +# define VCOL_HLC (wlv.vcol - wlv.vcol_off_co - wlv.vcol_off_tp - wlv.lbr_padding) # define FIX_FOR_BOGUSCOLS \ { \ wlv.n_extra += wlv.vcol_off_co; \ @@ -1339,7 +1347,8 @@ win_line( // Check for columns to display for 'colorcolumn'. wlv.color_cols = wp->w_p_cc_cols; if (wlv.color_cols != NULL) - wlv.draw_color_col = advance_color_col(VCOL_HLC, &wlv.color_cols); + wlv.draw_color_col = + advance_color_col(VCOL_HLC - wlv.sbr_padding, &wlv.color_cols); #endif #ifdef FEAT_TERMINAL @@ -3111,8 +3120,21 @@ win_line( wlv.c_extra = mb_off > 0 ? MB_FILLER_CHAR : ' '; wlv.c_final = NUL; # ifdef FEAT_PROP_POPUP - if (wlv.n_extra > 0 && c != TAB) - in_linebreak = TRUE; + if (wlv.n_extra > 0 && c != TAB) + { + in_linebreak = TRUE; + + // edge case: current col is colorcol + if (wlv.draw_color_col && VCOL_HLC == *wlv.color_cols) + { + vcol_save_attr = wlv.char_attr; + wlv.char_attr = + hl_combine_attr(wlv.char_attr, HL_ATTR(HLF_MC)); + } + + wlv.lbr_padding += win_lbr_chartabsize(&cts, NULL) - 1; + wlv.is_extra = 1; + } # endif if (VIM_ISWHITE(c)) { @@ -3971,7 +3993,8 @@ win_line( #ifdef FEAT_SYN_HL // advance to the next 'colorcolumn' if (wlv.draw_color_col) - wlv.draw_color_col = advance_color_col(VCOL_HLC, &wlv.color_cols); + wlv.draw_color_col = + advance_color_col(VCOL_HLC - wlv.sbr_padding, &wlv.color_cols); // Highlight the cursor column if 'cursorcolumn' is set. But don't // highlight the cursor position itself. @@ -3991,14 +4014,14 @@ win_line( # endif ) { - if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol + if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol - wlv.lbr_padding && lnum != wp->w_cursor.lnum) { vcol_save_attr = wlv.char_attr; wlv.char_attr = hl_combine_attr(wlv.char_attr, HL_ATTR(HLF_CUC)); } - else if (wlv.draw_color_col && VCOL_HLC == *wlv.color_cols) + else if (wlv.draw_color_col && VCOL_HLC - wlv.sbr_padding == *wlv.color_cols && !wlv.is_extra) { vcol_save_attr = wlv.char_attr; wlv.char_attr = hl_combine_attr(wlv.char_attr, HL_ATTR(HLF_MC)); @@ -4434,6 +4457,10 @@ win_line( #endif } + + if (wlv.n_extra == 0) + wlv.is_extra = 0; + } // for every character in the line #ifdef FEAT_PROP_POPUP vim_free(text_props); diff --git a/src/testdir/dumps/Test_colorcolumn_2.dump b/src/testdir/dumps/Test_colorcolumn_2.dump index 44e0e7a2da..44aa2296d1 100644 --- a/src/testdir/dumps/Test_colorcolumn_2.dump +++ b/src/testdir/dumps/Test_colorcolumn_2.dump @@ -1,5 +1,5 @@ ->T+0&#ffffff0|h|e| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|e|d| |o|v|e|r| |t|h|e| @3| +0&#ffd7d7255 -@1| +0&#ffffff0|l+0&#ffd7d7255|a+0&#ffffff0|z|y| |d|o|g|s| @28 +>T+0&#ffffff0|h|e| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|e|d| |o|v|e|r| |t|h|e| @4 +@2|l|a|z|y+0&#ffd7d7255| |d+0&#ffffff0|o+0&#ffd7d7255|g+0&#ffffff0|s| @28 |~+0#4040ff13&| @38 |~| @38 |~| @38 diff --git a/src/testdir/dumps/Test_conceal_cuc_01.dump b/src/testdir/dumps/Test_conceal_cuc_01.dump index bf4281999c..c2235458ff 100644 --- a/src/testdir/dumps/Test_conceal_cuc_01.dump +++ b/src/testdir/dumps/Test_conceal_cuc_01.dump @@ -1,8 +1,8 @@ |o+0&#ffffff0|n|e| |o|n|e| |o|n|e| @1|o|n|e| |o|n|e| |o|n|e| |o+0&#e0e0e08|n+0&#ffffff0|e| @11 -| +0#4040ff13&|>@2| |o+0#0000000&|n|e| |o+0&#ffd7d7255|n+0&#ffffff0|e| |o|n|e| |o|n|e| @19 +| +0#4040ff13&|>@2| |o+0#0000000&|n|e| |o|n|e| |o|n|e| |o+0&#ffd7d7255|n+0&#ffffff0|e| @19 |t|w|o| |t|w|o| |t|w|o| |t|w|o| |||h|i|d@1|e|n||| >h|e|r|e| |t|w|o| |t|w|o| @2 |t|h|r|e@1| @1|t|h|r|e@1| |t|h|r|e@1| |t|h|r|e@1| |t+0&#e0e0e08|h+0&#ffffff0|r|e@1| @9 -| +0#4040ff13&|>@2| |t+0#0000000&|h|r|e|e+0&#ffd7d7255| +0&#ffffff0|t|h|r|e@1| |t|h|r|e@1| |t|h|r|e@1| @11 +| +0#4040ff13&|>@2| |t+0#0000000&|h|r|e@1| |t|h|r|e|e+0&#ffd7d7255| +0&#ffffff0|t|h|r|e@1| |t|h|r|e@1| @11 |~+0#4040ff13&| @38 |~| @38 |~| @38 diff --git a/src/testdir/dumps/Test_conceal_cuc_02.dump b/src/testdir/dumps/Test_conceal_cuc_02.dump index 1b6662e985..427a8e28b7 100644 --- a/src/testdir/dumps/Test_conceal_cuc_02.dump +++ b/src/testdir/dumps/Test_conceal_cuc_02.dump @@ -1,8 +1,8 @@ |o+0&#ffffff0|n|e| |o|n|e| |o|n|e| @1|o|n|e| |o|n|e| |o|n|e| |o|n|e| @11 -| +0#4040ff13&|>@2| |o+0#0000000&|n|e| |o+0&#ffd7d7255|n+0&#ffffff0|e| |o|n|e| |o|n|e| @19 +| +0#4040ff13&|>@2| |o+0#0000000&|n|e| |o|n|e| |o|n|e| |o+0&#ffd7d7255|n+0&#ffffff0|e| @19 |t|w|o| |t|w|o| |t|w|o| |t|w|o| |||h|i|d@1|e|n||| |h|e|r|e| |t|w|o| |t|w>o| @2 |t|h|r|e@1| @1|t|h|r|e@1| |t|h|r|e@1| |t|h|r|e@1| |t|h|r|e@1| @9 -| +0#4040ff13&|>@2| |t+0#0000000&|h|r|e|e+0&#ffd7d7255| +0&#ffffff0|t|h|r|e@1| |t|h|r|e@1| |t|h|r|e@1| @11 +| +0#4040ff13&|>@2| |t+0#0000000&|h|r|e@1| |t|h|r|e|e+0&#ffd7d7255| +0&#ffffff0|t|h|r|e@1| |t|h|r|e@1| @11 |~+0#4040ff13&| @38 |~| @38 |~| @38