To: vim_dev@googlegroups.com Subject: Patch 9.0.0995 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0995 Problem: Padding before virtual text below is highlighted when 'number' and 'nowrap' are set. Solution: Save and restore n_attr_skip. (closes #11643) Files: src/drawline.c, src/testdir/test_textprop.vim, src/testdir/dumps/Test_prop_below_after_empty_3.dump *** ../vim-9.0.0994/src/drawline.c 2022-12-02 16:39:40.955082306 +0000 --- src/drawline.c 2022-12-02 21:35:01.509021800 +0000 *************** *** 141,146 **** --- 141,147 ---- char_u *p_extra_free; // p_extra buffer that needs to be freed int extra_attr; // attributes for p_extra, should be combined // 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 c_final; // final char, mandatory if set int extra_for_textprop; // wlv.n_extra set for textprop *************** *** 149,154 **** --- 150,156 ---- int saved_n_extra; char_u *saved_p_extra; int saved_extra_attr; + int saved_n_attr_skip; int saved_extra_for_textprop; int saved_c_extra; int saved_c_final; *************** *** 652,664 **** int strsize = vim_strsize(*p_extra); int cells = wrap ? strsize : textprop_size_after_trunc(wp, tp->tp_flags, before, padding, *p_extra, &n_used); - int cont_on_next_line = below && col_with_padding > win_col_off(wp) - && !wp->w_p_wrap; if (wrap || right || above || below || padding > 0 || n_used < *n_extra) { int col_off = win_col_off(wp) - win_col_off2(wp); - int skip_add = 0; if (above) { --- 654,663 ---- *************** *** 690,703 **** before = 0; else n_used = *n_extra; - skip_add = col_off; } else before = 0; } - else if (below && before > 0) - // include 'number' column et al. - skip_add = col_off; } // With 'nowrap' add one to show the "extends" character if needed (it --- 689,698 ---- *************** *** 707,714 **** && wp->w_lcs_chars.ext != NUL && wp->w_p_list) ++n_used; - if (!wp->w_p_wrap && below && padding > 0) - skip_add = col_off; // add 1 for NUL, 2 for when '…' is used if (n_attr != NULL) --- 702,707 ---- *************** *** 763,772 **** if (above) *n_attr -= padding + after; ! // Add "skip_add" when starting a new line or wrapping, ! // n_attr_skip will then be decremented in the number column. ! *n_attr_skip = before + padding ! + (cont_on_next_line || before > 0 ? skip_add : 0); } } } --- 756,764 ---- if (above) *n_attr -= padding + after; ! // n_attr_skip will not be decremented before draw_state is ! // WL_LINE ! *n_attr_skip = before + padding; } } } *************** *** 946,951 **** --- 938,944 ---- wlv->saved_n_extra = wlv->n_extra; wlv->saved_p_extra = wlv->p_extra; wlv->saved_extra_attr = wlv->extra_attr; + wlv->saved_n_attr_skip = wlv->n_attr_skip; wlv->saved_extra_for_textprop = wlv->extra_for_textprop; wlv->saved_c_extra = wlv->c_extra; wlv->saved_c_final = wlv->c_final; *************** *** 959,965 **** --- 952,961 ---- else #endif wlv->saved_char_attr = 0; + + // these are not used until restored in win_line_continue() wlv->n_extra = 0; + wlv->n_attr_skip = 0; } } *************** *** 978,983 **** --- 974,980 ---- wlv->c_final = wlv->saved_c_final; wlv->p_extra = wlv->saved_p_extra; wlv->extra_attr = wlv->saved_extra_attr; + wlv->n_attr_skip = wlv->saved_n_attr_skip; wlv->extra_for_textprop = wlv->saved_extra_for_textprop; wlv->char_attr = wlv->saved_char_attr; } *************** *** 1021,1027 **** // prec until it's been used int n_attr = 0; // chars with special attr - int n_attr_skip = 0; // chars to skip bef. using wlv.extra_attr int saved_attr2 = 0; // char_attr saved for n_attr int n_attr3 = 0; // chars with overruling special attr int saved_attr3 = 0; // char_attr saved for n_attr3 --- 1018,1023 ---- *************** *** 2063,2069 **** wlv.vcol, wlv.col, &wlv.n_extra, &wlv.p_extra, ! &n_attr, &n_attr_skip); if (wlv.p_extra != prev_p_extra) { // wlv.p_extra was allocated --- 2059,2065 ---- wlv.vcol, wlv.col, &wlv.n_extra, &wlv.p_extra, ! &n_attr, &wlv.n_attr_skip); if (wlv.p_extra != prev_p_extra) { // wlv.p_extra was allocated *************** *** 2105,2113 **** { wlv.n_extra -= skip_cells; wlv.p_extra += skip_cells; ! n_attr_skip -= skip_cells; ! if (n_attr_skip < 0) ! n_attr_skip = 0; skip_cells = 0; } else --- 2101,2109 ---- { wlv.n_extra -= skip_cells; wlv.p_extra += skip_cells; ! wlv.n_attr_skip -= skip_cells; ! if (wlv.n_attr_skip < 0) ! wlv.n_attr_skip = 0; skip_cells = 0; } else *************** *** 2116,2122 **** // it and advance to the next one skip_cells -= wlv.n_extra; wlv.n_extra = 0; ! n_attr_skip = 0; bail_out = TRUE; } } --- 2112,2118 ---- // it and advance to the next one skip_cells -= wlv.n_extra; wlv.n_extra = 0; ! wlv.n_attr_skip = 0; bail_out = TRUE; } } *************** *** 3337,3344 **** // Use "wlv.extra_attr", but don't override visual selection // highlighting, unless text property overrides. ! // Don't use "wlv.extra_attr" until n_attr_skip is zero. ! if (n_attr_skip == 0 && n_attr > 0 && wlv.draw_state == WL_LINE && (!attr_pri #ifdef FEAT_PROP_POPUP --- 3333,3340 ---- // Use "wlv.extra_attr", but don't override visual selection // highlighting, unless text property overrides. ! // Don't use "wlv.extra_attr" until wlv.n_attr_skip is zero. ! if (wlv.n_attr_skip == 0 && n_attr > 0 && wlv.draw_state == WL_LINE && (!attr_pri #ifdef FEAT_PROP_POPUP *************** *** 3828,3837 **** // restore attributes after last 'listchars' or 'number' char if (n_attr > 0 && wlv.draw_state == WL_LINE ! && n_attr_skip == 0 && --n_attr == 0) wlv.char_attr = saved_attr2; ! if (n_attr_skip > 0) ! --n_attr_skip; // At end of screen line and there is more to come: Display the line // so far. If there is no more to display it is caught above. --- 3824,3833 ---- // restore attributes after last 'listchars' or 'number' char if (n_attr > 0 && wlv.draw_state == WL_LINE ! && wlv.n_attr_skip == 0 && --n_attr == 0) wlv.char_attr = saved_attr2; ! if (wlv.n_attr_skip > 0) ! --wlv.n_attr_skip; // At end of screen line and there is more to come: Display the line // so far. If there is no more to display it is caught above. *** ../vim-9.0.0994/src/testdir/test_textprop.vim 2022-12-02 20:46:01.940019452 +0000 --- src/testdir/test_textprop.vim 2022-12-02 21:24:38.289655530 +0000 *************** *** 2747,2752 **** --- 2747,2755 ---- call term_sendkeys(buf, ":set number\") call VerifyScreenDump(buf, 'Test_prop_below_after_empty_2', {}) + call term_sendkeys(buf, ":set nowrap\") + call VerifyScreenDump(buf, 'Test_prop_below_after_empty_3', {}) + call StopVimInTerminal(buf) endfunc *** ../vim-9.0.0994/src/testdir/dumps/Test_prop_below_after_empty_3.dump 2022-12-02 21:49:47.040229365 +0000 --- src/testdir/dumps/Test_prop_below_after_empty_3.dump 2022-12-02 21:30:19.297294347 +0000 *************** *** 0 **** --- 1,8 ---- + | +0#af5f00255#ffffff0@1|1| >v+0#0000000&|i|m|9|s|c|r|i|p|t| @45 + | +0#af5f00255&@1|2| | +0#0000000&@55 + | +0#af5f00255&@3| +0#0000000&|T+0#ffffff16#e000002|h|e| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| |t|h|e| |l|a|z|y| |d|o|g| +0#0000000#ffffff0@11 + | +0#af5f00255&@1|3| |t+0#0000000&|h|r|e@1| @50 + | +0#af5f00255&@1|4| | +0#0000000&@55 + | +0#af5f00255&@3|T+0#0000000#ffd7ff255|h|e| |s|l|o|w| |f|o|x| |b|u|m|p|s| |i|n|t|o| |t|h|e| |l|a|z|y| |d|o|g| +0&#ffffff0@19 + |~+0#4040ff13&| @58 + |:+0#0000000&|s|e|t| |n|o|w|r|a|p| @30|1|,|1| @10|A|l@1| *** ../vim-9.0.0994/src/version.c 2022-12-02 21:37:36.400878227 +0000 --- src/version.c 2022-12-02 21:38:36.740823136 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 995, /**/ -- hundred-and-one symptoms of being an internet addict: 214. Your MCI "Circle of Friends" are all Hayes-compatible. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///