# HG changeset patch # User Richard M. Stallman # Date 889912482 0 # Node ID 15d4310cb9e738a613ed75e9ace5a2bf1294a765 # Parent aba31b37562b3742d8ff07891f1988d9829b4647 (insert_1_both, insert_from_string_1, insert_from_buffer_1) (adjust_after_replace, replace_range): Account for combining bytes in args to record_insert. (del_range_2): Make undo records for combining bytes. Put second call to move_gap_both before setting beg_unchanged. diff -r aba31b37562b -r 15d4310cb9e7 src/insdel.c --- a/src/insdel.c Sat Mar 14 21:45:49 1998 +0000 +++ b/src/insdel.c Sat Mar 14 21:54:42 1998 +0000 @@ -911,7 +911,8 @@ if (combined_before_bytes) record_delete (PT - 1, 1); - record_insert (PT - !!combined_before_bytes, nchars); + record_insert (PT - !!combined_before_bytes, + nchars - combined_before_bytes + !!combined_before_bytes); MODIFF++; bcopy (string, GPT_ADDR, nbytes); @@ -1081,7 +1082,8 @@ if (combined_before_bytes) record_delete (PT - 1, 1); - record_insert (PT - !!combined_before_bytes, nchars); + record_insert (PT - !!combined_before_bytes, + nchars - combined_before_bytes + !!combined_before_bytes); MODIFF++; GAP_SIZE -= outgoing_nbytes; @@ -1236,7 +1238,8 @@ if (combined_before_bytes) record_delete (PT - 1, 1); - record_insert (PT - !!combined_before_bytes, nchars); + record_insert (PT - !!combined_before_bytes, + nchars - combined_before_bytes + !!combined_before_bytes); MODIFF++; GAP_SIZE -= outgoing_nbytes; @@ -1333,7 +1336,8 @@ move_gap_both (GPT + combined_after_bytes, GPT_BYTE + combined_after_bytes); - record_insert (from - !!combined_before_bytes, len); + record_insert (from - !!combined_before_bytes, + len - combined_before_bytes + !!combined_before_bytes); adjust_overlays_for_insert (from, len); adjust_markers_for_insert (from, from_byte, from + len, from_byte + len_byte, @@ -1500,7 +1504,8 @@ if (combined_before_bytes) record_delete (PT - 1, 1); - record_insert (from, inschars); + record_insert (PT - !!combined_before_bytes, + inschars - combined_before_bytes + !!combined_before_bytes); GAP_SIZE -= outgoing_insbytes; GPT += inschars; @@ -1695,13 +1700,17 @@ if (to < GPT) gap_left (to, to_byte, 0); + combined_after_bytes + = count_combining_before (GAP_END_ADDR, ZV_BYTE - GPT_BYTE, PT, PT_BYTE); + /* Relocate all markers pointing into the new, larger gap to point at the end of the text before the gap. Do this before recording the deletion, so that undo handles this after reinserting the text. */ adjust_markers_for_delete (from, from_byte, to, to_byte); - record_delete (from, nchars_del); + record_delete (from - !!combined_after_bytes, + nchars_del + combined_after_bytes + !!combined_after_bytes); MODIFF++; /* Relocate point as if it were a marker. */ @@ -1725,6 +1734,10 @@ GPT_BYTE = from_byte; *(GPT_ADDR) = 0; /* Put an anchor. */ + if (combined_after_bytes) + move_gap_both (GPT + combined_after_bytes, + GPT_BYTE + combined_after_bytes); + if (GPT_BYTE < GPT) abort (); @@ -1733,15 +1746,11 @@ if (Z - GPT < end_unchanged) end_unchanged = Z - GPT; - combined_after_bytes - = count_combining_before (GAP_END_ADDR, ZV_BYTE - GPT_BYTE, PT, PT_BYTE); + if (combined_after_bytes) + combine_bytes (PT, PT_BYTE, combined_after_bytes); if (combined_after_bytes) - move_gap_both (GPT + combined_after_bytes, - GPT_BYTE + combined_after_bytes); - - if (combined_after_bytes) - combine_bytes (PT, PT_BYTE, combined_after_bytes); + record_insert (GPT - 1, 1); evaporate_overlays (from); signal_after_change (from, nchars_del, 0);