diff options
| author | Kenichi Handa | 2000-05-22 00:19:43 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-05-22 00:19:43 +0000 |
| commit | adee4f912ad6593dc92dd04ea1f8e0f9ef315ccb (patch) | |
| tree | 13918205ac63a6922d269dead3d109b0e36d627f /src | |
| parent | d7e00792f2da10db36cfed619a19c8715bc74063 (diff) | |
| download | emacs-adee4f912ad6593dc92dd04ea1f8e0f9ef315ccb.tar.gz emacs-adee4f912ad6593dc92dd04ea1f8e0f9ef315ccb.zip | |
(adjust_markers_for_replace): Fix previous change.
(adjust_after_replace): If PREV_TEXT is nil, call
adjust_markers_for_insert, not adjust_markers_for_replace.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/insdel.c b/src/insdel.c index a2756e4e2ed..101e74207c4 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -462,7 +462,8 @@ adjust_point (nchars, nbytes) | |||
| 462 | 462 | ||
| 463 | /* Adjust markers for a replacement of a text at FROM (FROM_BYTE) of | 463 | /* Adjust markers for a replacement of a text at FROM (FROM_BYTE) of |
| 464 | length OLD_CHARS (OLD_BYTES) to a new text of length NEW_CHARS | 464 | length OLD_CHARS (OLD_BYTES) to a new text of length NEW_CHARS |
| 465 | (NEW_BYTES). */ | 465 | (NEW_BYTES). It is assumed that OLD_CHARS > 0, i.e., this is not |
| 466 | an insertion. */ | ||
| 466 | 467 | ||
| 467 | static void | 468 | static void |
| 468 | adjust_markers_for_replace (from, from_byte, old_chars, old_bytes, | 469 | adjust_markers_for_replace (from, from_byte, old_chars, old_bytes, |
| @@ -478,17 +479,12 @@ adjust_markers_for_replace (from, from_byte, old_chars, old_bytes, | |||
| 478 | { | 479 | { |
| 479 | register struct Lisp_Marker *m = XMARKER (marker); | 480 | register struct Lisp_Marker *m = XMARKER (marker); |
| 480 | 481 | ||
| 481 | if (m->bytepos >= prev_to_byte | 482 | if (m->bytepos >= prev_to_byte) |
| 482 | && (old_bytes != 0 | ||
| 483 | /* If this is an insertion (replacing 0 chars), | ||
| 484 | reject the case of a marker that is at the | ||
| 485 | insertion point and should stay before the insertion. */ | ||
| 486 | || m->bytepos > from_byte || m->insertion_type)) | ||
| 487 | { | 483 | { |
| 488 | m->charpos = min (from + new_chars, m->charpos + diff_chars); | 484 | m->charpos += diff_chars; |
| 489 | m->bytepos = min (from_byte + new_bytes, m->bytepos + diff_bytes); | 485 | m->bytepos += diff_bytes; |
| 490 | } | 486 | } |
| 491 | else if (m->bytepos >= from_byte) | 487 | else if (m->bytepos > from_byte) |
| 492 | { | 488 | { |
| 493 | m->charpos = from; | 489 | m->charpos = from; |
| 494 | m->bytepos = from_byte; | 490 | m->bytepos = from_byte; |
| @@ -1277,8 +1273,12 @@ adjust_after_replace (from, from_byte, prev_text, len, len_byte) | |||
| 1277 | GPT += len; GPT_BYTE += len_byte; | 1273 | GPT += len; GPT_BYTE += len_byte; |
| 1278 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | 1274 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ |
| 1279 | 1275 | ||
| 1280 | adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, | 1276 | if (nchars_del > 0) |
| 1281 | len, len_byte); | 1277 | adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, |
| 1278 | len, len_byte); | ||
| 1279 | else | ||
| 1280 | adjust_markers_for_insert (from, from_byte, | ||
| 1281 | from + len, from_byte + len_byte, 0); | ||
| 1282 | 1282 | ||
| 1283 | if (! EQ (current_buffer->undo_list, Qt)) | 1283 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1284 | { | 1284 | { |