summaryrefslogtreecommitdiffstats
path: root/src/textprop.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-13 18:34:18 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-13 18:34:18 +0100
commit3b93cf218fc70897c11de0415221e7899e9a527a (patch)
tree2c7c401ba41ccc52d15f7e30b62ccc75c08102c2 /src/textprop.c
parenta04f457a6c071179bac4088c9314007d39d5c5e0 (diff)
patch 9.0.0458: splitting a line with a text prop "above" moves it downv9.0.0458
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.
Diffstat (limited to 'src/textprop.c')
-rw-r--r--src/textprop.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/textprop.c b/src/textprop.c
index be7225445a..d2536ce776 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -2264,6 +2264,7 @@ adjust_props_for_split(
proptype_T *pt;
int start_incl, end_incl;
int cont_prev, cont_next;
+ int prop_col;
// copy the prop to an aligned structure
mch_memmove(&prop, props + i * sizeof(textprop_T), sizeof(textprop_T));
@@ -2271,9 +2272,13 @@ adjust_props_for_split(
pt = text_prop_type_by_id(curbuf, prop.tp_type);
start_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL));
end_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL));
- cont_prev = prop.tp_col != MAXCOL && prop.tp_col + !start_incl <= kept;
- cont_next = prop.tp_col != MAXCOL
- && skipped <= prop.tp_col + prop.tp_len - !end_incl;
+
+ // 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;
// when a prop has text it is never copied
if (prop.tp_id < 0 && cont_next)
cont_prev = FALSE;
@@ -2292,8 +2297,7 @@ adjust_props_for_split(
// Only add the property to the next line if the length is bigger than
// zero.
- if ((cont_next || prop.tp_col == MAXCOL)
- && ga_grow(&nextprop, 1) == OK)
+ if ((cont_next || prop_col == MAXCOL) && ga_grow(&nextprop, 1) == OK)
{
textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len;