summaryrefslogtreecommitdiff
path: root/test/lisp/replace-tests.el
diff options
context:
space:
mode:
authorTino Calancha <tino.calancha@gmail.com>2018-04-09 11:47:47 +0900
committerTino Calancha <tino.calancha@gmail.com>2018-04-09 11:47:47 +0900
commit32dc0cb1b5ae895d237c7118ccaeb084715934fd (patch)
treefb8f4645d3584fdf5281bc78e662d5c893e56bea /test/lisp/replace-tests.el
parent24f7defaf79e5afc38f40de01c78a4a7ed51dbd4 (diff)
downloademacs-32dc0cb1b5ae895d237c7118ccaeb084715934fd.tar.gz
Preserve case in query-replace undo
If the user query and replaces 'foo' with 'BAR', then undo must comeback to 'foo', not to 'FOO' (Bug#31073). * lisp/replace.el (perform-replace): Bind nocasify to non-nil value during undo/undo-all actions. * test/lisp/replace-tests.el (query-replace-undo-bug31073): Add test.
Diffstat (limited to 'test/lisp/replace-tests.el')
-rw-r--r--test/lisp/replace-tests.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el
index 66c68426607..40a1a31cf7c 100644
--- a/test/lisp/replace-tests.el
+++ b/test/lisp/replace-tests.el
@@ -380,4 +380,24 @@ Each element has the format:
(should (string= "211" (replace-tests--query-replace-undo)))
(should (string= "211" (replace-tests--query-replace-undo 'comma))))
+(ert-deftest query-replace-undo-bug31073 ()
+ "Test for https://debbugs.gnu.org/31073 ."
+ (let ((text "aaa aaa")
+ (count 0))
+ (with-temp-buffer
+ (insert text)
+ (goto-char 1)
+ (cl-letf (((symbol-function 'read-event)
+ (lambda (&rest args)
+ (cl-incf count)
+ (let ((val (pcase count
+ ((or 1 2 3) ?\s) ; replace current and go next
+ (4 ?U) ; undo-all
+ (_ ?q)))) ; exit
+ val))))
+ (perform-replace "a" "B" t nil nil))
+ ;; After undo text must be the same.
+ (should (string= text (buffer-string))))))
+
+
;;; replace-tests.el ends here