]> git.eshelyaron.com Git - emacs.git/commitdiff
(adjust_markers_for_delete): Handle before-insertion markers correctly.
authorMiles Bader <miles@gnu.org>
Wed, 18 Oct 2000 06:20:27 +0000 (06:20 +0000)
committerMiles Bader <miles@gnu.org>
Wed, 18 Oct 2000 06:20:27 +0000 (06:20 +0000)
src/ChangeLog
src/insdel.c

index 41cee2636b082b30147a70fc2d254e092c5fa332..9337d6b8e014c03ceb95f09c6c244243361aa59d 100644 (file)
@@ -1,3 +1,8 @@
+2000-10-18  Miles Bader  <miles@lsi.nec.co.jp>
+
+       * insdel.c (adjust_markers_for_delete): Handle before-insertion
+       markers correctly.
+
 2000-10-17  Gerd Moellmann  <gerd@gnu.org>
 
        * alloc.c (pure_bytes_used): Renamed from pureptr.
index 4229fb6abb531c72be1fd986194ab00ce0b83983..e89ad9292bf2e4341f24239a196a509a6619f5b3 100644 (file)
@@ -1,5 +1,5 @@
 /* Buffer insertion/deletion and gap motion for GNU Emacs.
-   Copyright (C) 1985, 86,93,94,95,97,98, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -366,14 +366,33 @@ adjust_markers_for_delete (from, from_byte, to, to_byte)
          m->charpos -= to - from;
          m->bytepos -= to_byte - from_byte;
        }
-
       /* Here's the case where a marker is inside text being deleted.  */
       else if (charpos > from)
        {
-         record_marker_adjustment (marker, from - charpos);
+         if (! m->insertion_type)
+           /* Normal markers will end up at the beginning of the
+              re-inserted text after undoing a deletion, and must be
+              adjusted to move them to the correct place.  */ 
+           record_marker_adjustment (marker, from - charpos);
+         else if (charpos < to)
+           /* Before-insertion markers will automatically move forward
+              upon re-inserting the deleted text, so we have to arrange
+              for them to move backward to the correct position.  */
+           record_marker_adjustment (marker, charpos - to);
+
          m->charpos = from;
          m->bytepos = from_byte;
        }
+      /* Here's the case where a before-insertion marker is immediately
+        before the deleted region.  */
+      else if (charpos == from && m->insertion_type)
+       {
+         /* Undoing the change uses normal insertion, which will
+            incorrectly make MARKER move forward, so we arrange for it
+            to then move backward to the correct place at the beginning
+            of the deleted region.  */
+         record_marker_adjustment (marker, to - from);
+       }
 
       marker = m->chain;
     }