diff options
| author | Barry O'Reilly | 2014-03-02 12:37:32 -0500 |
|---|---|---|
| committer | Barry O'Reilly | 2014-03-02 12:37:32 -0500 |
| commit | e3d090b4c50756f1ed9db55553a98b515eec5eaa (patch) | |
| tree | 9b0c093244886dc48b60d7b2a678cc6b6b97d6a6 | |
| parent | b923819c10d71fe1824d0c25787a16a38d08d926 (diff) | |
| download | emacs-e3d090b4c50756f1ed9db55553a98b515eec5eaa.tar.gz emacs-e3d090b4c50756f1ed9db55553a98b515eec5eaa.zip | |
* 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
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/simple.el | 2 | ||||
| -rw-r--r-- | test/ChangeLog | 7 | ||||
| -rw-r--r-- | test/automated/undo-tests.el | 42 |
4 files changed, 55 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 17f225708a2..a2a88f4b86b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-03-02 Barry O'Reilly <gundaetiapo@gmail.com> | ||
| 2 | |||
| 3 | * simple.el (undo-elt-in-region): Fix buffer corruption for edge | ||
| 4 | case of undo in region. | ||
| 5 | |||
| 1 | 2014-03-02 Martin Rudalics <rudalics@gmx.at> | 6 | 2014-03-02 Martin Rudalics <rudalics@gmx.at> |
| 2 | 7 | ||
| 3 | * window.el (fit-window-to-buffer): Fix argument in window-size | 8 | * window.el (fit-window-to-buffer): Fix argument in window-size |
diff --git a/lisp/simple.el b/lisp/simple.el index bf8b6a75ac7..18448331ff0 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2426,7 +2426,7 @@ If it crosses the edge, we return nil." | |||
| 2426 | ((stringp (car undo-elt)) | 2426 | ((stringp (car undo-elt)) |
| 2427 | ;; (TEXT . POSITION) | 2427 | ;; (TEXT . POSITION) |
| 2428 | (and (>= (abs (cdr undo-elt)) start) | 2428 | (and (>= (abs (cdr undo-elt)) start) |
| 2429 | (< (abs (cdr undo-elt)) end))) | 2429 | (<= (abs (cdr undo-elt)) end))) |
| 2430 | ((and (consp undo-elt) (markerp (car undo-elt))) | 2430 | ((and (consp undo-elt) (markerp (car undo-elt))) |
| 2431 | ;; This is a marker-adjustment element (MARKER . ADJUSTMENT). | 2431 | ;; This is a marker-adjustment element (MARKER . ADJUSTMENT). |
| 2432 | ;; See if MARKER is inside the region. | 2432 | ;; See if MARKER is inside the region. |
diff --git a/test/ChangeLog b/test/ChangeLog index 9082f2ace2a..41416baa3aa 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-03-02 Barry O'Reilly <gundaetiapo@gmail.com> | ||
| 2 | |||
| 3 | * automated/undo-tests.el (undo-test-in-region-not-most-recent): | ||
| 4 | Add new test of undo in region. | ||
| 5 | (undo-test-in-region-eob): Add test case described at | ||
| 6 | http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16411 | ||
| 7 | |||
| 1 | 2014-02-28 Michael Albinus <michael.albinus@gmx.de> | 8 | 2014-02-28 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 9 | ||
| 3 | * automated/tramp-tests.el (tramp--test-enabled) | 10 | * automated/tramp-tests.el (tramp--test-enabled) |
diff --git a/test/automated/undo-tests.el b/test/automated/undo-tests.el index 53af574a8ee..8a963f10028 100644 --- a/test/automated/undo-tests.el +++ b/test/automated/undo-tests.el | |||
| @@ -226,6 +226,48 @@ | |||
| 226 | (should-not (buffer-modified-p)))) | 226 | (should-not (buffer-modified-p)))) |
| 227 | (delete-file tempfile)))) | 227 | (delete-file tempfile)))) |
| 228 | 228 | ||
| 229 | (ert-deftest undo-test-in-region-not-most-recent () | ||
| 230 | "Test undo in region of an edit not the most recent." | ||
| 231 | (with-temp-buffer | ||
| 232 | (buffer-enable-undo) | ||
| 233 | (transient-mark-mode 1) | ||
| 234 | (insert "1111") | ||
| 235 | (undo-boundary) | ||
| 236 | (goto-char 2) | ||
| 237 | (insert "2") | ||
| 238 | (forward-char 2) | ||
| 239 | (undo-boundary) | ||
| 240 | (insert "3") | ||
| 241 | (undo-boundary) | ||
| 242 | ;; Highlight around "2", not "3" | ||
| 243 | (push-mark (+ 3 (point-min)) t t) | ||
| 244 | (setq mark-active t) | ||
| 245 | (goto-char (point-min)) | ||
| 246 | (undo) | ||
| 247 | (should (string= (buffer-string) | ||
| 248 | "11131")))) | ||
| 249 | |||
| 250 | (ert-deftest undo-test-in-region-eob () | ||
| 251 | "Test undo in region of a deletion at EOB, demonstrating bug 16411." | ||
| 252 | (with-temp-buffer | ||
| 253 | (buffer-enable-undo) | ||
| 254 | (transient-mark-mode 1) | ||
| 255 | (insert "This sentence corrupted?") | ||
| 256 | (undo-boundary) | ||
| 257 | ;; Same as recipe at | ||
| 258 | ;; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16411 | ||
| 259 | (insert "aaa") | ||
| 260 | (undo-boundary) | ||
| 261 | (undo) | ||
| 262 | ;; Select entire buffer | ||
| 263 | (push-mark (point) t t) | ||
| 264 | (setq mark-active t) | ||
| 265 | (goto-char (point-min)) | ||
| 266 | ;; Should undo the undo of "aaa", ie restore it. | ||
| 267 | (undo) | ||
| 268 | (should (string= (buffer-string) | ||
| 269 | "This sentence corrupted?aaa")))) | ||
| 270 | |||
| 229 | (defun undo-test-all (&optional interactive) | 271 | (defun undo-test-all (&optional interactive) |
| 230 | "Run all tests for \\[undo]." | 272 | "Run all tests for \\[undo]." |
| 231 | (interactive "p") | 273 | (interactive "p") |