comparison src/textprop.c @ 30245:8f85b5c45432 v9.0.0458

patch 9.0.0458: splitting a line with a text prop "above" moves it down Commit: https://github.com/vim/vim/commit/3b93cf218fc70897c11de0415221e7899e9a527a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 13 18:34:18 2022 +0100 patch 9.0.0458: splitting a line with a text prop "above" moves it down Problem: Splitting a line with a text prop "above" moves it to a new line below. Solution: Keep an "above" text prop above the first line.
author Bram Moolenaar <Bram@vim.org>
date Tue, 13 Sep 2022 19:45:03 +0200
parents 8d660a45299f
children c0c7a6748061
comparison
equal deleted inserted replaced
30244:30f106bef844 30245:8f85b5c45432
2262 { 2262 {
2263 textprop_T prop; 2263 textprop_T prop;
2264 proptype_T *pt; 2264 proptype_T *pt;
2265 int start_incl, end_incl; 2265 int start_incl, end_incl;
2266 int cont_prev, cont_next; 2266 int cont_prev, cont_next;
2267 int prop_col;
2267 2268
2268 // copy the prop to an aligned structure 2269 // copy the prop to an aligned structure
2269 mch_memmove(&prop, props + i * sizeof(textprop_T), sizeof(textprop_T)); 2270 mch_memmove(&prop, props + i * sizeof(textprop_T), sizeof(textprop_T));
2270 2271
2271 pt = text_prop_type_by_id(curbuf, prop.tp_type); 2272 pt = text_prop_type_by_id(curbuf, prop.tp_type);
2272 start_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL)); 2273 start_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL));
2273 end_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL)); 2274 end_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL));
2274 cont_prev = prop.tp_col != MAXCOL && prop.tp_col + !start_incl <= kept; 2275
2275 cont_next = prop.tp_col != MAXCOL 2276 // a text prop "above" behaves like it is on the first text column
2276 && skipped <= prop.tp_col + prop.tp_len - !end_incl; 2277 prop_col = (prop.tp_flags & TP_FLAG_ALIGN_ABOVE) ? 1 : prop.tp_col;
2278
2279 cont_prev = prop_col != MAXCOL && prop_col + !start_incl <= kept;
2280 cont_next = prop_col != MAXCOL
2281 && skipped <= prop_col + prop.tp_len - !end_incl;
2277 // when a prop has text it is never copied 2282 // when a prop has text it is never copied
2278 if (prop.tp_id < 0 && cont_next) 2283 if (prop.tp_id < 0 && cont_next)
2279 cont_prev = FALSE; 2284 cont_prev = FALSE;
2280 2285
2281 if (cont_prev && ga_grow(&prevprop, 1) == OK) 2286 if (cont_prev && ga_grow(&prevprop, 1) == OK)
2290 p->tp_flags |= TP_FLAG_CONT_NEXT; 2295 p->tp_flags |= TP_FLAG_CONT_NEXT;
2291 } 2296 }
2292 2297
2293 // Only add the property to the next line if the length is bigger than 2298 // Only add the property to the next line if the length is bigger than
2294 // zero. 2299 // zero.
2295 if ((cont_next || prop.tp_col == MAXCOL) 2300 if ((cont_next || prop_col == MAXCOL) && ga_grow(&nextprop, 1) == OK)
2296 && ga_grow(&nextprop, 1) == OK)
2297 { 2301 {
2298 textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len; 2302 textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len;
2299 2303
2300 *p = prop; 2304 *p = prop;
2301 ++nextprop.ga_len; 2305 ++nextprop.ga_len;