]> git.eshelyaron.com Git - emacs.git/commitdiff
* simple.el (undo-elt-in-region): Fix buffer corruption for edge
authorBarry O'Reilly <gundaetiapo@gmail.com>
Sun, 2 Mar 2014 17:37:32 +0000 (12:37 -0500)
committerBarry O'Reilly <gundaetiapo@gmail.com>
Sun, 2 Mar 2014 17:37:32 +0000 (12:37 -0500)
case of undo in region.
* automated/undo-tests.el (undo-test-in-region-not-most-recent):
Add new test of undo in region.
(undo-test-in-region-eob): Add test case described at
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16411#41

lisp/ChangeLog
lisp/simple.el
test/ChangeLog
test/automated/undo-tests.el

index 17f225708a22ad82265c48472370da78b37740ca..a2a88f4b86bceef517b854d65b6b550962f6b79b 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-02  Barry O'Reilly <gundaetiapo@gmail.com>
+
+       * simple.el (undo-elt-in-region): Fix buffer corruption for edge
+       case of undo in region.
+
 2014-03-02  Martin Rudalics  <rudalics@gmx.at>
 
        * window.el (fit-window-to-buffer): Fix argument in window-size
index bf8b6a75ac73f042e9336ed2033d6e27e1e5e398..18448331ff06d5f397db39d6b94ebf9f0c1833c1 100644 (file)
@@ -2426,7 +2426,7 @@ If it crosses the edge, we return nil."
        ((stringp (car undo-elt))
         ;; (TEXT . POSITION)
         (and (>= (abs (cdr undo-elt)) start)
-             (< (abs (cdr undo-elt)) end)))
+             (<= (abs (cdr undo-elt)) end)))
        ((and (consp undo-elt) (markerp (car undo-elt)))
         ;; This is a marker-adjustment element (MARKER . ADJUSTMENT).
         ;; See if MARKER is inside the region.
index 9082f2ace2a0c1243778c78052adafdd42a235e2..41416baa3aae7997dbeb6eb9f1a80e50a77a95d1 100644 (file)
@@ -1,3 +1,10 @@
+2014-03-02  Barry O'Reilly <gundaetiapo@gmail.com>
+
+       * automated/undo-tests.el (undo-test-in-region-not-most-recent):
+       Add new test of undo in region.
+       (undo-test-in-region-eob): Add test case described at
+       http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16411
+
 2014-02-28  Michael Albinus  <michael.albinus@gmx.de>
 
        * automated/tramp-tests.el (tramp--test-enabled)
index 53af574a8eedad723f578ca4b3c4e6817b3568ee..8a963f100284b30cd4dc4f54a352db193c7f667e 100644 (file)
             (should-not (buffer-modified-p))))
       (delete-file tempfile))))
 
+(ert-deftest undo-test-in-region-not-most-recent ()
+  "Test undo in region of an edit not the most recent."
+  (with-temp-buffer
+    (buffer-enable-undo)
+    (transient-mark-mode 1)
+    (insert "1111")
+    (undo-boundary)
+    (goto-char 2)
+    (insert "2")
+    (forward-char 2)
+    (undo-boundary)
+    (insert "3")
+    (undo-boundary)
+    ;; Highlight around "2", not "3"
+    (push-mark (+ 3 (point-min)) t t)
+    (setq mark-active t)
+    (goto-char (point-min))
+    (undo)
+    (should (string= (buffer-string)
+                     "11131"))))
+
+(ert-deftest undo-test-in-region-eob ()
+  "Test undo in region of a deletion at EOB, demonstrating bug 16411."
+  (with-temp-buffer
+    (buffer-enable-undo)
+    (transient-mark-mode 1)
+    (insert "This sentence corrupted?")
+    (undo-boundary)
+    ;; Same as recipe at
+    ;; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16411
+    (insert "aaa")
+    (undo-boundary)
+    (undo)
+    ;; Select entire buffer
+    (push-mark (point) t t)
+    (setq mark-active t)
+    (goto-char (point-min))
+    ;; Should undo the undo of "aaa", ie restore it.
+    (undo)
+    (should (string= (buffer-string)
+                     "This sentence corrupted?aaa"))))
+
 (defun undo-test-all (&optional interactive)
   "Run all tests for \\[undo]."
   (interactive "p")