Patch 9.0.0962

2 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 27, 2022, 3:55:47 PM11/27/22
to vim...@googlegroups.com

Patch 9.0.0962
Problem: Virtual text below cannot be placed below empty lines.
Solution: Add one character. (James Alvarado, closes #11606, closes #11520)
Files: src/drawline.c, src/testdir/test_textprop.vim,
src/testdir/dumps/Test_prop_below_after_empty_1.dump


*** ../vim-9.0.0961/src/drawline.c 2022-11-24 23:03:58.952997387 +0000
--- src/drawline.c 2022-11-27 20:51:49.953895494 +0000
***************
*** 621,627 ****
text_prop_position(
win_T *wp,
textprop_T *tp,
! int vcol UNUSED, // current text column
int scr_col, // current screen column
int *n_extra, // nr of bytes for virtual text
char_u **p_extra, // virtual text
--- 621,627 ----
text_prop_position(
win_T *wp,
textprop_T *tp,
! int vcol, // current text column
int scr_col, // current screen column
int *n_extra, // nr of bytes for virtual text
char_u **p_extra, // virtual text
***************
*** 633,639 ****
int below = (tp->tp_flags & TP_FLAG_ALIGN_BELOW);
int wrap = (tp->tp_flags & TP_FLAG_WRAP);
int padding = tp->tp_col == MAXCOL && tp->tp_len > 1
! ? tp->tp_len - 1 : 0;
int col_with_padding = scr_col + (below ? 0 : padding);
int room = wp->w_width - col_with_padding;
int before = room; // spaces before the text
--- 633,639 ----
int below = (tp->tp_flags & TP_FLAG_ALIGN_BELOW);
int wrap = (tp->tp_flags & TP_FLAG_WRAP);
int padding = tp->tp_col == MAXCOL && tp->tp_len > 1
! ? tp->tp_len - 1 : 0;
int col_with_padding = scr_col + (below ? 0 : padding);
int room = wp->w_width - col_with_padding;
int before = room; // spaces before the text
***************
*** 661,671 ****
// Right-align: fill with before
if (right)
before -= cells;
if (before < 0
|| !(right || below)
! || (below
! ? (col_with_padding <= col_off || !wp->w_p_wrap)
! : (n_used < *n_extra)))
{
if (right && (wrap
|| (room < PROP_TEXT_MIN_CELLS && wp->w_p_wrap)))
--- 661,676 ----
// Right-align: fill with before
if (right)
before -= cells;
+
+ // Below-align: empty line add one character
+ if (below && vcol == 0 && col_with_padding == 0
+ && wp->w_width == before)
+ col_with_padding = 1;
+
if (before < 0
|| !(right || below)
! || (below ? (col_with_padding <= col_off || !wp->w_p_wrap)
! : (n_used < *n_extra)))
{
if (right && (wrap
|| (room < PROP_TEXT_MIN_CELLS && wp->w_p_wrap)))
*** ../vim-9.0.0961/src/testdir/test_textprop.vim 2022-11-24 22:42:06.927385902 +0000
--- src/testdir/test_textprop.vim 2022-11-27 20:53:55.705934487 +0000
***************
*** 2714,2719 ****
--- 2714,2752 ----
call StopVimInTerminal(buf)
endfunc

+ func Test_prop_with_text_below_after_empty()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ vim9script
+
+ setline(1, ['vim9script', '', 'three', ''])
+
+ # Add text prop below empty line 2 with padding.
+ prop_type_add('test', {highlight: 'ErrorMsg'})
+ prop_add(2, 0, {
+ type: 'test',
+ text: 'The quick brown fox jumps over the lazy dog',
+ text_align: 'below',
+ text_padding_left: 1,
+ })
+
+ # Add text prop below empty line 4 without padding.
+ prop_type_add('other', {highlight: 'DiffChange'})
+ prop_add(4, 0, {
+ type: 'other',
+ text: 'The slow fox bumps into the lazy dog',
+ text_align: 'below',
+ text_padding_left: 0,
+ })
+ END
+ call writefile(lines, 'XscriptPropBelowAfterEmpty', 'D')
+ let buf = RunVimInTerminal('-S XscriptPropBelowAfterEmpty', #{rows: 8, cols: 60})
+ call VerifyScreenDump(buf, 'Test_prop_below_after_empty_1', {})
+
+ call StopVimInTerminal(buf)
+ endfunc
+
func Test_prop_with_text_below_after_match()
CheckRunVimInTerminal

*** ../vim-9.0.0961/src/testdir/dumps/Test_prop_below_after_empty_1.dump 2022-11-27 20:54:34.553946199 +0000
--- src/testdir/dumps/Test_prop_below_after_empty_1.dump 2022-11-27 20:53:31.525927130 +0000
***************
*** 0 ****
--- 1,8 ----
+ >v+0&#ffffff0|i|m|9|s|c|r|i|p|t| @49
+ @60
+ @1|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@15
+ |t|h|r|e@1| @54
+ @60
+ |T+0&#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@23
+ |~+0#4040ff13&| @58
+ | +0#0000000&@41|1|,|1| @10|A|l@1|
*** ../vim-9.0.0961/src/version.c 2022-11-27 19:45:45.706989832 +0000
--- src/version.c 2022-11-27 20:40:18.189622380 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 962,
/**/

--
hundred-and-one symptoms of being an internet addict:
165. You have a web page burned into your glasses

/// Bram Moolenaar -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages