0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 9.0.0151: a "below" aligned text property does not work with 'nowrap'

Problem:    A "below" aligned text property does not work with 'nowrap'.
Solution:   Start a new screen line to display the virtual text.
            (closes #10851)
This commit is contained in:
Bram Moolenaar
2022-08-06 13:48:20 +01:00
parent 25f40af9d2
commit 4d91d347e6
7 changed files with 468 additions and 341 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -364,9 +364,6 @@ plines_win_nofill(
#endif
int lines;
if (!wp->w_p_wrap)
return 1;
if (wp->w_width == 0)
return 1;
@@ -377,7 +374,16 @@ plines_win_nofill(
return 1;
#endif
lines = plines_win_nofold(wp, lnum);
if (!wp->w_p_wrap)
lines = 1
#ifdef FEAT_PROP_POPUP
// add a line for each "below" aligned text property
+ prop_count_below(wp->w_buffer, lnum)
#endif
;
else
lines = plines_win_nofold(wp, lnum);
if (winheight > 0 && lines > wp->w_height)
return wp->w_height;
return lines;

View File

@@ -4,6 +4,7 @@ void f_prop_add(typval_T *argvars, typval_T *rettv);
void f_prop_add_list(typval_T *argvars, typval_T *rettv);
int prop_add_common(linenr_T start_lnum, colnr_T start_col, dict_T *dict, buf_T *default_buf, typval_T *dict_arg);
int get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change);
int prop_count_below(buf_T *buf, linenr_T lnum);
int count_props(linenr_T lnum, int only_starting, int last_line);
int find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop, linenr_T *found_lnum);
void add_text_props(linenr_T lnum, textprop_T *text_props, int text_prop_count);

View File

@@ -0,0 +1,8 @@
|o+0&#ffffff0|n|e| @56
| +0#ffffff16#e000002|B|e|l|o|w| |t|h|e| |l|i|n|e| | +0#0000000#ffffff0@43
|t|w|o| @56
|a+0&#ffff4012|n|o|t|h|e|r| +0&#ffffff0@52
|O+0#ffffff16#e000002|n|e| |M|o|r|e| |H|e|r|e| +0#0000000#ffffff0@46
|t|h|r|e>e| @54
|~+0#4040ff13&| @58
| +0#0000000&@41|3|,|5| @10|A|l@1|

View File

@@ -2426,6 +2426,27 @@ func Test_props_with_text_after_wraps()
call delete('XscriptPropsWithTextAfterWraps')
endfunc
func Test_props_with_text_after_nowrap()
CheckRunVimInTerminal
let lines =<< trim END
set nowrap
call setline(1, ['one', 'two', 'three'])
call prop_type_add('belowprop', #{highlight: 'ErrorMsg'})
call prop_type_add('anotherprop', #{highlight: 'Search'})
call prop_add(1, 0, #{type: 'belowprop', text: ' Below the line ', text_align: 'below'})
call prop_add(2, 0, #{type: 'anotherprop', text: 'another', text_align: 'below'})
call prop_add(2, 0, #{type: 'belowprop', text: 'One More Here', text_align: 'below'})
normal G$
END
call writefile(lines, 'XscriptPropsAfterNowrap')
let buf = RunVimInTerminal('-S XscriptPropsAfterNowrap', #{rows: 8, cols: 60})
call VerifyScreenDump(buf, 'Test_prop_with_text_after_nowrap_1', {})
call StopVimInTerminal(buf)
call delete('XscriptPropsAfterNowrap')
endfunc
func Test_removed_prop_with_text_cleans_up_array()
new
call setline(1, 'some text here')

View File

@@ -594,6 +594,29 @@ get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change)
return (int)(proplen / sizeof(textprop_T));
}
/*
* Return the number of text properties with "below" alignment in line "lnum".
*/
int
prop_count_below(buf_T *buf, linenr_T lnum)
{
char_u *props;
int count = get_text_props(buf, lnum, &props, FALSE);
int result = 0;
textprop_T prop;
int i;
if (count == 0)
return 0;
for (i = 0; i < count; ++i)
{
mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
if (prop.tp_col == MAXCOL && (prop.tp_flags & TP_FLAG_ALIGN_BELOW))
++result;
}
return result;
}
/**
* Return the number of text properties on line "lnum" in the current buffer.
* When "only_starting" is true only text properties starting in this line will

View File

@@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
151,
/**/
150,
/**/