Problem: Virtual text wrong after adding line break after line.
Solution: Pass an "eol" flag to where text properties are adjusted.
(closes #11131)
int vreplace_mode;
int did_append; // appended a new line
int saved_pi = curbuf->b_p_pi; // copy of preserveindent setting
+#ifdef FEAT_PROP_POPUP
+ int at_eol; // cursor after last character
+#endif
// make a copy of the current line so we can mess with it
saved_line = vim_strsave(ml_get_curline());
if (saved_line == NULL) // out of memory!
return FALSE;
+#ifdef FEAT_PROP_POPUP
+ at_eol = curwin->w_cursor.col >= (int)STRLEN(saved_line);
+#endif
+
if (State & VREPLACE_FLAG)
{
// With MODE_VREPLACE we make a copy of the next line, which we will be
if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0)
// Properties after the split move to the next line.
adjust_props_for_split(curwin->w_cursor.lnum, curwin->w_cursor.lnum,
- curwin->w_cursor.col + 1, 0);
+ curwin->w_cursor.col + 1, 0, at_eol);
#endif
}
else
void clear_global_prop_types(void);
void clear_buf_prop_types(buf_T *buf);
int adjust_prop_columns(linenr_T lnum, colnr_T col, int bytes_added, int flags);
-void adjust_props_for_split(linenr_T lnum_props, linenr_T lnum_top, int kept, int deleted);
+void adjust_props_for_split(linenr_T lnum_props, linenr_T lnum_top, int kept, int deleted, int at_eol);
void prepend_joined_props(char_u *new_props, int propcount, int *props_remaining, linenr_T lnum, int last_line, long col, int removed);
/* vim: set ft=c : */
--- /dev/null
+|o+0&#ffffff0|n|e| |o|n|e| |o|n|e| @63
+|t|w|o| |t|w|o| |t|w|o| @63
+@3|└+2&&|─| |V|i|r|t|u|a|l| |t|e|x|t| |b|e|l|o|w| |t|h|e| |2|n|d| |l|i|n|e| +0&&@37
+|x@1> @72
+|t|h|r|e@1| |t|h|r|e@1| |t|h|r|e@1| @57
+|~+0#4040ff13&| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|3|,|3| @10|A|l@1|
call prop_type_delete('indented')
endfunc
+func Test_prop_below_split_line()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ vim9script
+ setline(1, ['one one one', 'two two two', 'three three three'])
+ prop_type_add('test', {highlight: 'ModeMsg'})
+ prop_add(2, 0, {
+ text: '└─ Virtual text below the 2nd line',
+ type: 'test',
+ text_align: 'below',
+ text_padding_left: 3
+ })
+ END
+ call writefile(lines, 'XscriptPropBelowSpitLine', 'D')
+ let buf = RunVimInTerminal('-S XscriptPropBelowSpitLine', #{rows: 8})
+ call term_sendkeys(buf, "2GA\<CR>xx")
+ call VerifyScreenDump(buf, 'Test_prop_below_split_line_1', {})
+
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_props_with_text_override()
CheckRunVimInTerminal
hi CursorLine cterm=underline ctermbg=lightgrey
set cursorline
END
- call writefile(lines, 'XscriptPropsOverride')
+ call writefile(lines, 'XscriptPropsOverride', 'D')
let buf = RunVimInTerminal('-S XscriptPropsOverride', #{rows: 6, cols: 60})
call VerifyScreenDump(buf, 'Test_prop_with_text_override_1', {})
call VerifyScreenDump(buf, 'Test_prop_with_text_override_2', {})
call StopVimInTerminal(buf)
- call delete('XscriptPropsOverride')
endfunc
func Test_props_with_text_CursorMoved()
* "lnum_top" is the top line.
* "kept" is the number of bytes kept in the first line, while
* "deleted" is the number of bytes deleted.
+ * "at_eol" is true if the split is after the end of the line.
*/
void
adjust_props_for_split(
- linenr_T lnum_props,
- linenr_T lnum_top,
- int kept,
- int deleted)
+ linenr_T lnum_props,
+ linenr_T lnum_top,
+ int kept,
+ int deleted,
+ int at_eol)
{
char_u *props;
int count;
// a text prop "above" behaves like it is on the first text column
prop_col = (prop.tp_flags & TP_FLAG_ALIGN_ABOVE) ? 1 : prop.tp_col;
- cont_prev = prop_col != MAXCOL && prop_col + !start_incl <= kept;
- cont_next = prop_col != MAXCOL
- && skipped <= prop_col + prop.tp_len - !end_incl;
+ if (prop_col == MAXCOL)
+ {
+ cont_prev = at_eol;
+ cont_next = !at_eol;
+ }
+ else
+ {
+ cont_prev = prop_col + !start_incl <= kept;
+ cont_next = skipped <= prop_col + prop.tp_len - !end_incl;
+ }
// when a prop has text it is never copied
if (prop.tp_id < 0 && cont_next)
cont_prev = FALSE;
// Only add the property to the next line if the length is bigger than
// zero.
- if ((cont_next || prop_col == MAXCOL) && ga_grow(&nextprop, 1) == OK)
+ if (cont_next && ga_grow(&nextprop, 1) == OK)
{
textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len;
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 466,
/**/
465,
/**/