mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 9.0.1301: virtual text below empty line not displayed
Problem: Virtual text below empty line not displayed. Solution: Adjust flags and computations. (closes #11959)
This commit is contained in:
@@ -1152,6 +1152,8 @@ win_lbr_chartabsize(
|
|||||||
* First get the normal size, without 'linebreak' or text properties
|
* First get the normal size, without 'linebreak' or text properties
|
||||||
*/
|
*/
|
||||||
size = win_chartabsize(wp, s, vcol);
|
size = win_chartabsize(wp, s, vcol);
|
||||||
|
if (*s == NUL)
|
||||||
|
size = 0; // NUL is not displayed
|
||||||
|
|
||||||
# ifdef FEAT_PROP_POPUP
|
# ifdef FEAT_PROP_POPUP
|
||||||
if (cts->cts_has_prop_with_text)
|
if (cts->cts_has_prop_with_text)
|
||||||
|
@@ -1085,6 +1085,7 @@ win_line(
|
|||||||
int save_did_emsg;
|
int save_did_emsg;
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_PROP_POPUP
|
#ifdef FEAT_PROP_POPUP
|
||||||
|
int did_line = FALSE; // set to TRUE when line text done
|
||||||
int text_prop_count;
|
int text_prop_count;
|
||||||
int text_prop_next = 0; // next text property to use
|
int text_prop_next = 0; // next text property to use
|
||||||
textprop_T *text_props = NULL;
|
textprop_T *text_props = NULL;
|
||||||
@@ -1914,17 +1915,20 @@ win_line(
|
|||||||
// Check if any active property ends.
|
// Check if any active property ends.
|
||||||
for (pi = 0; pi < text_props_active; ++pi)
|
for (pi = 0; pi < text_props_active; ++pi)
|
||||||
{
|
{
|
||||||
int tpi = text_prop_idxs[pi];
|
int tpi = text_prop_idxs[pi];
|
||||||
|
textprop_T *tp = &text_props[tpi];
|
||||||
|
|
||||||
if (text_props[tpi].tp_col != MAXCOL
|
// An inline property ends when after the start column plus
|
||||||
&& bcol >= text_props[tpi].tp_col - 1
|
// length. An "above" property ends when used and n_extra
|
||||||
+ text_props[tpi].tp_len)
|
// is zero.
|
||||||
|
if ((tp->tp_col != MAXCOL
|
||||||
|
&& bcol >= tp->tp_col - 1 + tp->tp_len))
|
||||||
{
|
{
|
||||||
if (pi + 1 < text_props_active)
|
if (pi + 1 < text_props_active)
|
||||||
mch_memmove(text_prop_idxs + pi,
|
mch_memmove(text_prop_idxs + pi,
|
||||||
text_prop_idxs + pi + 1,
|
text_prop_idxs + pi + 1,
|
||||||
sizeof(int)
|
sizeof(int)
|
||||||
* (text_props_active - (pi + 1)));
|
* (text_props_active - (pi + 1)));
|
||||||
--text_props_active;
|
--text_props_active;
|
||||||
--pi;
|
--pi;
|
||||||
# ifdef FEAT_LINEBREAK
|
# ifdef FEAT_LINEBREAK
|
||||||
@@ -1940,6 +1944,9 @@ win_line(
|
|||||||
// not on the next char yet, don't start another prop
|
// not on the next char yet, don't start another prop
|
||||||
--bcol;
|
--bcol;
|
||||||
# endif
|
# endif
|
||||||
|
int display_text_first = FALSE;
|
||||||
|
int active_before = text_props_active;
|
||||||
|
|
||||||
// Add any text property that starts in this column.
|
// Add any text property that starts in this column.
|
||||||
// With 'nowrap' and not in the first screen line only "below"
|
// With 'nowrap' and not in the first screen line only "below"
|
||||||
// text prop can show.
|
// text prop can show.
|
||||||
@@ -1950,16 +1957,24 @@ win_line(
|
|||||||
|| wlv.row == startrow
|
|| wlv.row == startrow
|
||||||
|| (text_props[text_prop_next].tp_flags
|
|| (text_props[text_prop_next].tp_flags
|
||||||
& TP_FLAG_ALIGN_BELOW)))
|
& TP_FLAG_ALIGN_BELOW)))
|
||||||
|| (bcol == 0 &&
|
|| (bcol == 0
|
||||||
(text_props[text_prop_next].tp_flags
|
&& (text_props[text_prop_next].tp_flags
|
||||||
& TP_FLAG_ALIGN_ABOVE)))
|
& TP_FLAG_ALIGN_ABOVE)))
|
||||||
: bcol >= text_props[text_prop_next].tp_col - 1))
|
: bcol >= text_props[text_prop_next].tp_col - 1))
|
||||||
{
|
{
|
||||||
if (text_props[text_prop_next].tp_col == MAXCOL
|
if (text_props[text_prop_next].tp_col == MAXCOL
|
||||||
&& *ptr == NUL && wp->w_p_list && lcs_eol_one > 0)
|
&& *ptr == NUL
|
||||||
|
&& ((wp->w_p_list && lcs_eol_one > 0)
|
||||||
|
|| (ptr == line
|
||||||
|
&& !did_line
|
||||||
|
&& (text_props[text_prop_next].tp_flags
|
||||||
|
& TP_FLAG_ALIGN_BELOW))))
|
||||||
{
|
{
|
||||||
// first display the '$' after the line
|
// first display the '$' after the line or display an
|
||||||
|
// empty line
|
||||||
text_prop_follows = TRUE;
|
text_prop_follows = TRUE;
|
||||||
|
if (text_props_active == active_before)
|
||||||
|
display_text_first = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (text_props[text_prop_next].tp_col == MAXCOL
|
if (text_props[text_prop_next].tp_col == MAXCOL
|
||||||
@@ -1978,16 +1993,18 @@ win_line(
|
|||||||
text_prop_id = 0;
|
text_prop_id = 0;
|
||||||
reset_extra_attr = FALSE;
|
reset_extra_attr = FALSE;
|
||||||
}
|
}
|
||||||
if (text_props_active > 0 && wlv.n_extra == 0)
|
if (text_props_active > 0 && wlv.n_extra == 0
|
||||||
|
&& !display_text_first)
|
||||||
{
|
{
|
||||||
int used_tpi = -1;
|
int used_tpi = -1;
|
||||||
int used_attr = 0;
|
int used_attr = 0;
|
||||||
int other_tpi = -1;
|
int other_tpi = -1;
|
||||||
|
|
||||||
// Sort the properties on priority and/or starting last.
|
|
||||||
// Then combine the attributes, highest priority last.
|
|
||||||
text_prop_above = FALSE;
|
text_prop_above = FALSE;
|
||||||
text_prop_follows = FALSE;
|
text_prop_follows = FALSE;
|
||||||
|
|
||||||
|
// Sort the properties on priority and/or starting last.
|
||||||
|
// Then combine the attributes, highest priority last.
|
||||||
sort_text_props(wp->w_buffer, text_props,
|
sort_text_props(wp->w_buffer, text_props,
|
||||||
text_prop_idxs, text_props_active);
|
text_prop_idxs, text_props_active);
|
||||||
|
|
||||||
@@ -2159,8 +2176,8 @@ win_line(
|
|||||||
// must wrap anyway.
|
// must wrap anyway.
|
||||||
text_prop_above = above;
|
text_prop_above = above;
|
||||||
text_prop_follows |= other_tpi != -1
|
text_prop_follows |= other_tpi != -1
|
||||||
&& (wp->w_p_wrap
|
&& (wp->w_p_wrap
|
||||||
|| (text_props[other_tpi].tp_flags
|
|| (text_props[other_tpi].tp_flags
|
||||||
& (TP_FLAG_ALIGN_BELOW | TP_FLAG_ALIGN_RIGHT)));
|
& (TP_FLAG_ALIGN_BELOW | TP_FLAG_ALIGN_RIGHT)));
|
||||||
|
|
||||||
if (bail_out)
|
if (bail_out)
|
||||||
@@ -2495,6 +2512,12 @@ win_line(
|
|||||||
#ifdef FEAT_LINEBREAK
|
#ifdef FEAT_LINEBREAK
|
||||||
c0 = *ptr;
|
c0 = *ptr;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef FEAT_PROP_POPUP
|
||||||
|
if (c == NUL)
|
||||||
|
// text is finished, may display a "below" virtual text
|
||||||
|
did_line = TRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
{
|
{
|
||||||
mb_c = c;
|
mb_c = c;
|
||||||
@@ -3576,20 +3599,31 @@ win_line(
|
|||||||
// At end of the text line.
|
// At end of the text line.
|
||||||
if (c == NUL)
|
if (c == NUL)
|
||||||
{
|
{
|
||||||
draw_screen_line(wp, &wlv);
|
#ifdef FEAT_PROP_POPUP
|
||||||
|
if (text_prop_follows)
|
||||||
// Update w_cline_height and w_cline_folded if the cursor line was
|
|
||||||
// updated (saves a call to plines() later).
|
|
||||||
if (wp == curwin && lnum == curwin->w_cursor.lnum)
|
|
||||||
{
|
{
|
||||||
curwin->w_cline_row = startrow;
|
// Put the pointer back to the NUL.
|
||||||
curwin->w_cline_height = wlv.row - startrow;
|
--ptr;
|
||||||
#ifdef FEAT_FOLDING
|
c = ' ';
|
||||||
curwin->w_cline_folded = FALSE;
|
}
|
||||||
#endif
|
else
|
||||||
curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW);
|
#endif
|
||||||
|
{
|
||||||
|
draw_screen_line(wp, &wlv);
|
||||||
|
|
||||||
|
// Update w_cline_height and w_cline_folded if the cursor line
|
||||||
|
// was updated (saves a call to plines() later).
|
||||||
|
if (wp == curwin && lnum == curwin->w_cursor.lnum)
|
||||||
|
{
|
||||||
|
curwin->w_cline_row = startrow;
|
||||||
|
curwin->w_cline_height = wlv.row - startrow;
|
||||||
|
#ifdef FEAT_FOLDING
|
||||||
|
curwin->w_cline_folded = FALSE;
|
||||||
|
#endif
|
||||||
|
curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show "extends" character from 'listchars' if beyond the line end and
|
// Show "extends" character from 'listchars' if beyond the line end and
|
||||||
|
16
src/testdir/dumps/Test_prop_above_below_empty_1.dump
Normal file
16
src/testdir/dumps/Test_prop_above_below_empty_1.dump
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
| +0#af5f00255#ffffff0@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
| +0#af5f00255&@1|1| |1+0#0000000&@7| @47
|
||||||
|
| +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
| +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
| +0#af5f00255&@1|2| | +0#0000000&@55
|
||||||
|
| +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
| +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
| +0#af5f00255&@1|3| |3+0#0000000&@8| @46
|
||||||
|
| +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
| +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
| +0#af5f00255&@1|4| | +0#0000000&@55
|
||||||
|
| +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
| +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
| +0#af5f00255&@1|5| >5+0#0000000&@10| @44
|
||||||
|
| +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
|
||||||
|
@42|5|,|1|-|5|7| @7|A|l@1|
|
@@ -2779,6 +2779,28 @@ func Test_prop_with_text_below_after_empty()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_prop_with_text_above_below_empty()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
setlocal number
|
||||||
|
call setline(1, ['11111111', '', '333333333', '', '55555555555'])
|
||||||
|
|
||||||
|
let vt = 'test'
|
||||||
|
call prop_type_add(vt, {'highlight': 'ToDo'})
|
||||||
|
for ln in range(1, line('$'))
|
||||||
|
call prop_add(ln, 0, {'type': vt, 'text': '---', 'text_align': 'above'})
|
||||||
|
call prop_add(ln, 0, {'type': vt, 'text': '+++', 'text_align': 'below'})
|
||||||
|
endfor
|
||||||
|
normal G
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XscriptPropAboveBelowEmpty', 'D')
|
||||||
|
let buf = RunVimInTerminal('-S XscriptPropAboveBelowEmpty', #{rows: 16, cols: 60})
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_above_below_empty_1', {})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_prop_with_text_below_after_match()
|
func Test_prop_with_text_below_after_match()
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1301,
|
||||||
/**/
|
/**/
|
||||||
1300,
|
1300,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user