emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r116632: * simple.el (undo-elt-in-region): Fix buffe


From: Barry O'Reilly
Subject: [Emacs-diffs] trunk r116632: * simple.el (undo-elt-in-region): Fix buffer corruption for edge
Date: Sun, 02 Mar 2014 17:44:14 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116632
revision-id: address@hidden
parent: address@hidden
committer: Barry O'Reilly <address@hidden>
branch nick: trunk
timestamp: Sun 2014-03-02 12:37:32 -0500
message:
  * simple.el (undo-elt-in-region): Fix buffer corruption for edge
  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
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/simple.el                 simple.el-20091113204419-o5vbwnq5f7feedwu-403
  test/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-8588
  test/automated/undo-tests.el   undotests.el-20130108184711-brlnvjau5r1ardib-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-03-02 12:04:29 +0000
+++ b/lisp/ChangeLog    2014-03-02 17:37:32 +0000
@@ -1,3 +1,8 @@
+2014-03-02  Barry O'Reilly <address@hidden>
+
+       * simple.el (undo-elt-in-region): Fix buffer corruption for edge
+       case of undo in region.
+
 2014-03-02  Martin Rudalics  <address@hidden>
 
        * window.el (fit-window-to-buffer): Fix argument in window-size

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2014-03-01 03:54:47 +0000
+++ b/lisp/simple.el    2014-03-02 17:37:32 +0000
@@ -2426,7 +2426,7 @@
        ((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.

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2014-02-28 08:47:43 +0000
+++ b/test/ChangeLog    2014-03-02 17:37:32 +0000
@@ -1,3 +1,10 @@
+2014-03-02  Barry O'Reilly <address@hidden>
+
+       * 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  <address@hidden>
 
        * automated/tramp-tests.el (tramp--test-enabled)

=== modified file 'test/automated/undo-tests.el'
--- a/test/automated/undo-tests.el      2014-01-01 07:43:34 +0000
+++ b/test/automated/undo-tests.el      2014-03-02 17:37:32 +0000
@@ -226,6 +226,48 @@
             (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")


reply via email to

[Prev in Thread] Current Thread [Next in Thread]