comparison src/textprop.c @ 30261:6b658ef69e93 v9.0.0466

patch 9.0.0466: virtual text wrong after adding line break after line Commit: https://github.com/vim/vim/commit/ebd0e8bb853cb744b60bf4f57011c4379ae4aaed Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 14 22:13:59 2022 +0100 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)
author Bram Moolenaar <Bram@vim.org>
date Wed, 14 Sep 2022 23:15:03 +0200
parents c0c7a6748061
children 43d942ff32ce
comparison
equal deleted inserted replaced
30260:742a12140d60 30261:6b658ef69e93
2230 * Adjust text properties for a line that was split in two. 2230 * Adjust text properties for a line that was split in two.
2231 * "lnum_props" is the line that has the properties from before the split. 2231 * "lnum_props" is the line that has the properties from before the split.
2232 * "lnum_top" is the top line. 2232 * "lnum_top" is the top line.
2233 * "kept" is the number of bytes kept in the first line, while 2233 * "kept" is the number of bytes kept in the first line, while
2234 * "deleted" is the number of bytes deleted. 2234 * "deleted" is the number of bytes deleted.
2235 * "at_eol" is true if the split is after the end of the line.
2235 */ 2236 */
2236 void 2237 void
2237 adjust_props_for_split( 2238 adjust_props_for_split(
2238 linenr_T lnum_props, 2239 linenr_T lnum_props,
2239 linenr_T lnum_top, 2240 linenr_T lnum_top,
2240 int kept, 2241 int kept,
2241 int deleted) 2242 int deleted,
2243 int at_eol)
2242 { 2244 {
2243 char_u *props; 2245 char_u *props;
2244 int count; 2246 int count;
2245 garray_T prevprop; 2247 garray_T prevprop;
2246 garray_T nextprop; 2248 garray_T nextprop;
2274 end_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL)); 2276 end_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL));
2275 2277
2276 // a text prop "above" behaves like it is on the first text column 2278 // a text prop "above" behaves like it is on the first text column
2277 prop_col = (prop.tp_flags & TP_FLAG_ALIGN_ABOVE) ? 1 : prop.tp_col; 2279 prop_col = (prop.tp_flags & TP_FLAG_ALIGN_ABOVE) ? 1 : prop.tp_col;
2278 2280
2279 cont_prev = prop_col != MAXCOL && prop_col + !start_incl <= kept; 2281 if (prop_col == MAXCOL)
2280 cont_next = prop_col != MAXCOL 2282 {
2281 && skipped <= prop_col + prop.tp_len - !end_incl; 2283 cont_prev = at_eol;
2284 cont_next = !at_eol;
2285 }
2286 else
2287 {
2288 cont_prev = prop_col + !start_incl <= kept;
2289 cont_next = skipped <= prop_col + prop.tp_len - !end_incl;
2290 }
2282 // when a prop has text it is never copied 2291 // when a prop has text it is never copied
2283 if (prop.tp_id < 0 && cont_next) 2292 if (prop.tp_id < 0 && cont_next)
2284 cont_prev = FALSE; 2293 cont_prev = FALSE;
2285 2294
2286 if (cont_prev && ga_grow(&prevprop, 1) == OK) 2295 if (cont_prev && ga_grow(&prevprop, 1) == OK)
2295 p->tp_flags |= TP_FLAG_CONT_NEXT; 2304 p->tp_flags |= TP_FLAG_CONT_NEXT;
2296 } 2305 }
2297 2306
2298 // Only add the property to the next line if the length is bigger than 2307 // Only add the property to the next line if the length is bigger than
2299 // zero. 2308 // zero.
2300 if ((cont_next || prop_col == MAXCOL) && ga_grow(&nextprop, 1) == OK) 2309 if (cont_next && ga_grow(&nextprop, 1) == OK)
2301 { 2310 {
2302 textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len; 2311 textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len;
2303 2312
2304 *p = prop; 2313 *p = prop;
2305 ++nextprop.ga_len; 2314 ++nextprop.ga_len;