[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: text-property/intervals question
From: |
Stefan Monnier |
Subject: |
Re: text-property/intervals question |
Date: |
Sun, 25 Nov 2001 21:16:38 -0500 |
> Is it legal for a `struct interval' to have a total_length field of 0?
>
> I was debugging Alex Schroeder's problem with overlays in comint
> buffers, and when I did:
>
> M-x global-font-lock-mode
> M-x shell
> M-x ansi-color-for-comint-mode-on
>
> and then in the shell buffer:
>
> ls --color /tmp
>
> Emacs hung.
>
> Upon investigation, it turns out that Fprevious_single_char_property_change
> was looping infinitely because Fprevious_property_change was returning
> a position the same as its argument (which it's not supposed to do).
>
> The reason is because in this code from Fprevious_property_change:
>
> /* Start with the interval containing the char before point. */
> if (i->position == XFASTINT (position))
> i = previous_interval (i);
>
> it turns out that the previous interval had a total_length field of 0,
> and so the previous interval was at the same position as `i'!
>
> If zero-length intervals are legal (I didn't think they were), then I
> suppose this could be fixed by changing the `if' to `while', but if they
> aren't legal, there's something funny going on. However, I don't
> really understand this code, so I'd appreciate any advice or help.
It seems that this bug is fixed by the patch below,
Stefan
--- intervals.c.~1.109.~ Mon Nov 12 20:06:41 2001
+++ intervals.c Sun Nov 25 21:15:13 2001
@@ -1690,7 +1690,7 @@
if (NULL_INTERVAL_P (source))
{
Lisp_Object buf;
- if (!inherit && ! NULL_INTERVAL_P (tree))
+ if (!inherit && !NULL_INTERVAL_P (tree) && length > 0)
{
XSETBUFFER (buf, buffer);
set_text_properties_1 (make_number (position),