To: vim_dev@googlegroups.com Subject: Patch 9.0.0705 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0705 Problem: Virtual text truncation does not take padding into account. Solution: Subtract the padding from the available space. (closes #11318) Files: src/drawline.c, src/testdir/test_textprop.vim, src/testdir/dumps/Test_long_text_with_padding_1.dump *** ../vim-9.0.0704/src/drawline.c 2022-10-08 11:45:49.764409792 +0100 --- src/drawline.c 2022-10-09 15:22:11.365611827 +0100 *************** *** 573,578 **** --- 573,579 ---- win_T *wp, int flags, // TP_FLAG_ALIGN_* int added, + int padding, char_u *text, int *n_used_ptr) { *************** *** 585,590 **** --- 586,593 ---- // if the remaining size is to small wrap anyway and use the next line if (space < PROP_TEXT_MIN_CELLS) space += wp->w_width; + if (flags & TP_FLAG_ALIGN_BELOW) + space -= padding; for (n_used = 0; n_used < len; n_used += (*mb_ptr2len)(text + n_used)) { int clen = ptr2cells(text + n_used); *************** *** 629,635 **** char_u *l = NULL; int strsize = vim_strsize(*p_extra); int cells = wrap ? strsize : textprop_size_after_trunc(wp, ! tp->tp_flags, before, *p_extra, &n_used); if (wrap || right || above || below || padding > 0 || n_used < *n_extra) { --- 632,638 ---- char_u *l = NULL; int strsize = vim_strsize(*p_extra); int cells = wrap ? strsize : textprop_size_after_trunc(wp, ! tp->tp_flags, before, padding, *p_extra, &n_used); if (wrap || right || above || below || padding > 0 || n_used < *n_extra) { *************** *** 715,721 **** // change last character to '…' lp -= (*mb_head_off)(l, lp); STRCPY(lp, "…"); ! n_used = lp - l + 3 - padding; } else // change last character to '>' --- 718,724 ---- // change last character to '…' lp -= (*mb_head_off)(l, lp); STRCPY(lp, "…"); ! n_used = lp - l + 3 - before - padding; } else // change last character to '>' *** ../vim-9.0.0704/src/testdir/test_textprop.vim 2022-09-20 17:57:31.826990773 +0100 --- src/testdir/test_textprop.vim 2022-10-09 14:27:45.931568014 +0100 *************** *** 3183,3188 **** --- 3183,3216 ---- call StopVimInTerminal(buf) endfunc + func Test_long_text_below_with_padding() + CheckRunVimInTerminal + + let lines =<< trim END + vim9script + setline(1, ['first line', 'second line']) + prop_type_add('theprop', {highlight: 'DiffChange'}) + prop_add(1, 0, { + type: 'theprop', + text: 'after '->repeat(20), + text_align: 'below', + text_padding_left: 3, + }) + prop_add(1, 0, { + type: 'theprop', + text: 'more '->repeat(20), + text_align: 'below', + text_padding_left: 30, + }) + normal 2Gw + END + call writefile(lines, 'XlongTextBelowWithPadding', 'D') + let buf = RunVimInTerminal('-S XlongTextBelowWithPadding', #{rows: 8, cols: 60}) + call VerifyScreenDump(buf, 'Test_long_text_with_padding_1', {}) + + call StopVimInTerminal(buf) + endfunc + func Test_insert_text_change_arg() CheckRunVimInTerminal *** ../vim-9.0.0704/src/testdir/dumps/Test_long_text_with_padding_1.dump 2022-10-09 15:25:35.717809607 +0100 --- src/testdir/dumps/Test_long_text_with_padding_1.dump 2022-10-09 15:23:19.773698652 +0100 *************** *** 0 **** --- 1,8 ---- + |f+0&#ffffff0|i|r|s|t| |l|i|n|e| @49 + @3|a+0&#ffd7ff255|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|… + | +0&#ffffff0@29|m+0&#ffd7ff255|o|r|e| |m|o|r|e| |m|o|r|e| |m|o|r|e| |m|o|r|e| |m|o|r|e|… + |s+0&#ffffff0|e|c|o|n|d| >l|i|n|e| @48 + |~+0#4040ff13&| @58 + |~| @58 + |~| @58 + | +0#0000000&@41|2|,|8| @10|A|l@1| *** ../vim-9.0.0704/src/version.c 2022-10-09 13:28:32.551786054 +0100 --- src/version.c 2022-10-09 14:20:36.293730678 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 705, /**/ -- GUARD #1: Where'd you get the coconut? ARTHUR: We found them. GUARD #1: Found them? In Mercea? The coconut's tropical! ARTHUR: What do you mean? GUARD #1: Well, this is a temperate zone. The Quest for the Holy Grail (Monty Python) /// 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 ///