aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/insdel.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/insdel.c b/src/insdel.c
index 1a677d070f0..843a76e3d83 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -911,7 +911,8 @@ insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers)
911 if (combined_before_bytes) 911 if (combined_before_bytes)
912 record_delete (PT - 1, 1); 912 record_delete (PT - 1, 1);
913 913
914 record_insert (PT - !!combined_before_bytes, nchars); 914 record_insert (PT - !!combined_before_bytes,
915 nchars - combined_before_bytes + !!combined_before_bytes);
915 MODIFF++; 916 MODIFF++;
916 917
917 bcopy (string, GPT_ADDR, nbytes); 918 bcopy (string, GPT_ADDR, nbytes);
@@ -1081,7 +1082,8 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes,
1081 if (combined_before_bytes) 1082 if (combined_before_bytes)
1082 record_delete (PT - 1, 1); 1083 record_delete (PT - 1, 1);
1083 1084
1084 record_insert (PT - !!combined_before_bytes, nchars); 1085 record_insert (PT - !!combined_before_bytes,
1086 nchars - combined_before_bytes + !!combined_before_bytes);
1085 MODIFF++; 1087 MODIFF++;
1086 1088
1087 GAP_SIZE -= outgoing_nbytes; 1089 GAP_SIZE -= outgoing_nbytes;
@@ -1236,7 +1238,8 @@ insert_from_buffer_1 (buf, from, nchars, inherit)
1236 if (combined_before_bytes) 1238 if (combined_before_bytes)
1237 record_delete (PT - 1, 1); 1239 record_delete (PT - 1, 1);
1238 1240
1239 record_insert (PT - !!combined_before_bytes, nchars); 1241 record_insert (PT - !!combined_before_bytes,
1242 nchars - combined_before_bytes + !!combined_before_bytes);
1240 MODIFF++; 1243 MODIFF++;
1241 1244
1242 GAP_SIZE -= outgoing_nbytes; 1245 GAP_SIZE -= outgoing_nbytes;
@@ -1333,7 +1336,8 @@ adjust_after_replace (from, from_byte, to, to_byte, len, len_byte)
1333 move_gap_both (GPT + combined_after_bytes, 1336 move_gap_both (GPT + combined_after_bytes,
1334 GPT_BYTE + combined_after_bytes); 1337 GPT_BYTE + combined_after_bytes);
1335 1338
1336 record_insert (from - !!combined_before_bytes, len); 1339 record_insert (from - !!combined_before_bytes,
1340 len - combined_before_bytes + !!combined_before_bytes);
1337 adjust_overlays_for_insert (from, len); 1341 adjust_overlays_for_insert (from, len);
1338 adjust_markers_for_insert (from, from_byte, 1342 adjust_markers_for_insert (from, from_byte,
1339 from + len, from_byte + len_byte, 1343 from + len, from_byte + len_byte,
@@ -1500,7 +1504,8 @@ replace_range (from, to, new, prepare, inherit)
1500 if (combined_before_bytes) 1504 if (combined_before_bytes)
1501 record_delete (PT - 1, 1); 1505 record_delete (PT - 1, 1);
1502 1506
1503 record_insert (from, inschars); 1507 record_insert (PT - !!combined_before_bytes,
1508 inschars - combined_before_bytes + !!combined_before_bytes);
1504 1509
1505 GAP_SIZE -= outgoing_insbytes; 1510 GAP_SIZE -= outgoing_insbytes;
1506 GPT += inschars; 1511 GPT += inschars;
@@ -1695,13 +1700,17 @@ del_range_2 (from, from_byte, to, to_byte)
1695 if (to < GPT) 1700 if (to < GPT)
1696 gap_left (to, to_byte, 0); 1701 gap_left (to, to_byte, 0);
1697 1702
1703 combined_after_bytes
1704 = count_combining_before (GAP_END_ADDR, ZV_BYTE - GPT_BYTE, PT, PT_BYTE);
1705
1698 /* Relocate all markers pointing into the new, larger gap 1706 /* Relocate all markers pointing into the new, larger gap
1699 to point at the end of the text before the gap. 1707 to point at the end of the text before the gap.
1700 Do this before recording the deletion, 1708 Do this before recording the deletion,
1701 so that undo handles this after reinserting the text. */ 1709 so that undo handles this after reinserting the text. */
1702 adjust_markers_for_delete (from, from_byte, to, to_byte); 1710 adjust_markers_for_delete (from, from_byte, to, to_byte);
1703 1711
1704 record_delete (from, nchars_del); 1712 record_delete (from - !!combined_after_bytes,
1713 nchars_del + combined_after_bytes + !!combined_after_bytes);
1705 MODIFF++; 1714 MODIFF++;
1706 1715
1707 /* Relocate point as if it were a marker. */ 1716 /* Relocate point as if it were a marker. */
@@ -1725,6 +1734,10 @@ del_range_2 (from, from_byte, to, to_byte)
1725 GPT_BYTE = from_byte; 1734 GPT_BYTE = from_byte;
1726 *(GPT_ADDR) = 0; /* Put an anchor. */ 1735 *(GPT_ADDR) = 0; /* Put an anchor. */
1727 1736
1737 if (combined_after_bytes)
1738 move_gap_both (GPT + combined_after_bytes,
1739 GPT_BYTE + combined_after_bytes);
1740
1728 if (GPT_BYTE < GPT) 1741 if (GPT_BYTE < GPT)
1729 abort (); 1742 abort ();
1730 1743
@@ -1733,15 +1746,11 @@ del_range_2 (from, from_byte, to, to_byte)
1733 if (Z - GPT < end_unchanged) 1746 if (Z - GPT < end_unchanged)
1734 end_unchanged = Z - GPT; 1747 end_unchanged = Z - GPT;
1735 1748
1736 combined_after_bytes
1737 = count_combining_before (GAP_END_ADDR, ZV_BYTE - GPT_BYTE, PT, PT_BYTE);
1738
1739 if (combined_after_bytes) 1749 if (combined_after_bytes)
1740 move_gap_both (GPT + combined_after_bytes, 1750 combine_bytes (PT, PT_BYTE, combined_after_bytes);
1741 GPT_BYTE + combined_after_bytes);
1742 1751
1743 if (combined_after_bytes) 1752 if (combined_after_bytes)
1744 combine_bytes (PT, PT_BYTE, combined_after_bytes); 1753 record_insert (GPT - 1, 1);
1745 1754
1746 evaporate_overlays (from); 1755 evaporate_overlays (from);
1747 signal_after_change (from, nchars_del, 0); 1756 signal_after_change (from, nchars_del, 0);