summaryrefslogtreecommitdiff
path: root/src/insdel.c
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2005-02-01 23:47:06 +0000
committerKenichi Handa <handa@m17n.org>2005-02-01 23:47:06 +0000
commit7077904e6b5f65c6758d9b7b1d092fc5579d4317 (patch)
tree3cf418cd82dee3b4d312fef9b6198ad05163e180 /src/insdel.c
parent1f8f8e684ad089a7666d78ed9a30e5cb2cb9253f (diff)
downloademacs-7077904e6b5f65c6758d9b7b1d092fc5579d4317.tar.gz
(replace_range_2): Fix bugs in adjusting markers and point.
Diffstat (limited to 'src/insdel.c')
-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 @@
/* Buffer insertion/deletion and gap motion for GNU Emacs.
- Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 01, 2003
+ Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 01, 2003, 2005
Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -1745,17 +1745,21 @@ replace_range_2 (from, from_byte, to, to_byte, ins, inschars, insbytes, markers)
/* Adjust markers for the deletion and the insertion. */
if (markers
- && ! (nchars_del == 1 && inschars == 1))
+ && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
inschars, insbytes);
offset_intervals (current_buffer, from, inschars - nchars_del);
/* Relocate point as if it were a marker. */
- if (from < PT && nchars_del != inschars)
- adjust_point ((from + inschars - (PT < to ? PT : to)),
- (from_byte + insbytes
- - (PT_BYTE < to_byte ? PT_BYTE : to_byte)));
+ if (from < PT && (nchars_del != inschars || nbytes_del != insbytes))
+ {
+ if (PT < to)
+ /* PT was within the deleted text. Move it to FROM. */
+ adjust_point (from - PT, from_byte - PT_BYTE);
+ else
+ adjust_point (inschars - nchars_del, insbytes - nbytes_del);
+ }
if (insbytes == 0)
evaporate_overlays (from);