aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2005-02-01 23:47:06 +0000
committerKenichi Handa2005-02-01 23:47:06 +0000
commit7077904e6b5f65c6758d9b7b1d092fc5579d4317 (patch)
tree3cf418cd82dee3b4d312fef9b6198ad05163e180 /src
parent1f8f8e684ad089a7666d78ed9a30e5cb2cb9253f (diff)
downloademacs-7077904e6b5f65c6758d9b7b1d092fc5579d4317.tar.gz
emacs-7077904e6b5f65c6758d9b7b1d092fc5579d4317.zip
(replace_range_2): Fix bugs in adjusting markers and point.
Diffstat (limited to 'src')
-rw-r--r--src/insdel.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/insdel.c b/src/insdel.c
index 7f10c2f523d..ad6623c6693 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1,5 +1,5 @@
1/* Buffer insertion/deletion and gap motion for GNU Emacs. 1/* Buffer insertion/deletion and gap motion for GNU Emacs.
2 Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 01, 2003 2 Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 01, 2003, 2005
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -1745,17 +1745,21 @@ replace_range_2 (from, from_byte, to, to_byte, ins, inschars, insbytes, markers)
1745 1745
1746 /* Adjust markers for the deletion and the insertion. */ 1746 /* Adjust markers for the deletion and the insertion. */
1747 if (markers 1747 if (markers
1748 && ! (nchars_del == 1 && inschars == 1)) 1748 && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
1749 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, 1749 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1750 inschars, insbytes); 1750 inschars, insbytes);
1751 1751
1752 offset_intervals (current_buffer, from, inschars - nchars_del); 1752 offset_intervals (current_buffer, from, inschars - nchars_del);
1753 1753
1754 /* Relocate point as if it were a marker. */ 1754 /* Relocate point as if it were a marker. */
1755 if (from < PT && nchars_del != inschars) 1755 if (from < PT && (nchars_del != inschars || nbytes_del != insbytes))
1756 adjust_point ((from + inschars - (PT < to ? PT : to)), 1756 {
1757 (from_byte + insbytes 1757 if (PT < to)
1758 - (PT_BYTE < to_byte ? PT_BYTE : to_byte))); 1758 /* PT was within the deleted text. Move it to FROM. */
1759 adjust_point (from - PT, from_byte - PT_BYTE);
1760 else
1761 adjust_point (inschars - nchars_del, insbytes - nbytes_del);
1762 }
1759 1763
1760 if (insbytes == 0) 1764 if (insbytes == 0)
1761 evaporate_overlays (from); 1765 evaporate_overlays (from);