From ebd0e8bb853cb744b60bf4f57011c4379ae4aaed Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 14 Sep 2022 22:13:59 +0100 Subject: patch 9.0.0466: virtual text wrong after adding line break after line Problem: Virtual text wrong after adding line break after line. Solution: Pass an "eol" flag to where text properties are adjusted. (closes #11131) --- src/textprop.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/textprop.c') diff --git a/src/textprop.c b/src/textprop.c index ba21e751b..6e5c1447f 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -2232,13 +2232,15 @@ adjust_prop_columns( * "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; @@ -2276,9 +2278,16 @@ adjust_props_for_split( // 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; @@ -2297,7 +2306,7 @@ adjust_props_for_split( // 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; -- cgit v1.2.1