diff options
Diffstat (limited to 'src/textprop.c')
-rw-r--r-- | src/textprop.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/textprop.c b/src/textprop.c index c4e49d98ebc..7af8c698736 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -2043,18 +2043,19 @@ add_text_properties_from_list (Lisp_Object object, Lisp_Object list, Lisp_Object end-points to NEW_END. */ Lisp_Object -extend_property_ranges (Lisp_Object list, Lisp_Object new_end) +extend_property_ranges (Lisp_Object list, Lisp_Object old_end, Lisp_Object new_end) { Lisp_Object prev = Qnil, head = list; ptrdiff_t max = XINT (new_end); for (; CONSP (list); prev = list, list = XCDR (list)) { - Lisp_Object item, beg, end; + Lisp_Object item, beg; + ptrdiff_t end; item = XCAR (list); beg = XCAR (item); - end = XCAR (XCDR (item)); + end = XINT (XCAR (XCDR (item))); if (XINT (beg) >= max) { @@ -2065,9 +2066,16 @@ extend_property_ranges (Lisp_Object list, Lisp_Object new_end) else XSETCDR (prev, XCDR (list)); } - else if (XINT (end) > max) - /* The end-point is past the end of the new string. */ - XSETCAR (XCDR (item), new_end); + else if ((end == XINT (old_end) && end != max) + || end > max) + { + /* Either the end-point is past the end of the new string, + and we need to discard the properties past the new end, + or the caller is extending the property range, and we + should update all end-points that are on the old end of + the range to reflect that. */ + XSETCAR (XCDR (item), new_end); + } } return head; |