diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/buffer.c b/src/buffer.c index 08031a0d72b..455b03efec2 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -3290,8 +3290,7 @@ adjust_overlays_for_delete (pos, length) | |||
| 3290 | endpoint in this range will need to be unlinked from the overlay | 3290 | endpoint in this range will need to be unlinked from the overlay |
| 3291 | list and reinserted in its proper place. | 3291 | list and reinserted in its proper place. |
| 3292 | Such an overlay might even have negative size at this point. | 3292 | Such an overlay might even have negative size at this point. |
| 3293 | If so, we'll reverse the endpoints. Can you think of anything | 3293 | If so, we'll make the overlay empty. */ |
| 3294 | better to do in this situation? */ | ||
| 3295 | void | 3294 | void |
| 3296 | fix_start_end_in_overlays (start, end) | 3295 | fix_start_end_in_overlays (start, end) |
| 3297 | register int start, end; | 3296 | register int start, end; |
| @@ -3318,23 +3317,24 @@ fix_start_end_in_overlays (start, end) | |||
| 3318 | for (parent = NULL, tail = current_buffer->overlays_before; tail;) | 3317 | for (parent = NULL, tail = current_buffer->overlays_before; tail;) |
| 3319 | { | 3318 | { |
| 3320 | XSETMISC (overlay, tail); | 3319 | XSETMISC (overlay, tail); |
| 3320 | |||
| 3321 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | 3321 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 3322 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | ||
| 3323 | |||
| 3324 | /* If the overlay is backwards, make it empty. */ | ||
| 3325 | if (endpos < startpos) | ||
| 3326 | { | ||
| 3327 | startpos = endpos; | ||
| 3328 | Fset_marker (OVERLAY_START (overlay), make_number (startpos), | ||
| 3329 | Qnil); | ||
| 3330 | } | ||
| 3331 | |||
| 3322 | if (endpos < start) | 3332 | if (endpos < start) |
| 3323 | break; | 3333 | break; |
| 3324 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | 3334 | |
| 3325 | if (endpos < end | 3335 | if (endpos < end |
| 3326 | || (startpos >= start && startpos < end)) | 3336 | || (startpos >= start && startpos < end)) |
| 3327 | { | 3337 | { |
| 3328 | /* If the overlay is backwards, fix that now. */ | ||
| 3329 | if (startpos > endpos) | ||
| 3330 | { | ||
| 3331 | int tem; | ||
| 3332 | Fset_marker (OVERLAY_START (overlay), make_number (endpos), | ||
| 3333 | Qnil); | ||
| 3334 | Fset_marker (OVERLAY_END (overlay), make_number (startpos), | ||
| 3335 | Qnil); | ||
| 3336 | tem = startpos; startpos = endpos; endpos = tem; | ||
| 3337 | } | ||
| 3338 | /* Add it to the end of the wrong list. Later on, | 3338 | /* Add it to the end of the wrong list. Later on, |
| 3339 | recenter_overlay_lists will move it to the right place. */ | 3339 | recenter_overlay_lists will move it to the right place. */ |
| 3340 | if (endpos < current_buffer->overlay_center) | 3340 | if (endpos < current_buffer->overlay_center) |
| @@ -3365,22 +3365,24 @@ fix_start_end_in_overlays (start, end) | |||
| 3365 | for (parent = NULL, tail = current_buffer->overlays_after; tail;) | 3365 | for (parent = NULL, tail = current_buffer->overlays_after; tail;) |
| 3366 | { | 3366 | { |
| 3367 | XSETMISC (overlay, tail); | 3367 | XSETMISC (overlay, tail); |
| 3368 | |||
| 3368 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | 3369 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 3370 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | ||
| 3371 | |||
| 3372 | /* If the overlay is backwards, make it empty. */ | ||
| 3373 | if (endpos < startpos) | ||
| 3374 | { | ||
| 3375 | startpos = endpos; | ||
| 3376 | Fset_marker (OVERLAY_START (overlay), make_number (startpos), | ||
| 3377 | Qnil); | ||
| 3378 | } | ||
| 3379 | |||
| 3369 | if (startpos >= end) | 3380 | if (startpos >= end) |
| 3370 | break; | 3381 | break; |
| 3371 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | 3382 | |
| 3372 | if (startpos >= start | 3383 | if (startpos >= start |
| 3373 | || (endpos >= start && endpos < end)) | 3384 | || (endpos >= start && endpos < end)) |
| 3374 | { | 3385 | { |
| 3375 | if (startpos > endpos) | ||
| 3376 | { | ||
| 3377 | int tem; | ||
| 3378 | Fset_marker (OVERLAY_START (overlay), make_number (endpos), | ||
| 3379 | Qnil); | ||
| 3380 | Fset_marker (OVERLAY_END (overlay), make_number (startpos), | ||
| 3381 | Qnil); | ||
| 3382 | tem = startpos; startpos = endpos; endpos = tem; | ||
| 3383 | } | ||
| 3384 | if (endpos < current_buffer->overlay_center) | 3386 | if (endpos < current_buffer->overlay_center) |
| 3385 | { | 3387 | { |
| 3386 | if (!afterp) | 3388 | if (!afterp) |