diff options
| author | Tino Calancha | 2018-04-09 11:47:47 +0900 |
|---|---|---|
| committer | Tino Calancha | 2018-04-09 11:47:47 +0900 |
| commit | 32dc0cb1b5ae895d237c7118ccaeb084715934fd (patch) | |
| tree | fb8f4645d3584fdf5281bc78e662d5c893e56bea /test | |
| parent | 24f7defaf79e5afc38f40de01c78a4a7ed51dbd4 (diff) | |
| download | emacs-32dc0cb1b5ae895d237c7118ccaeb084715934fd.tar.gz emacs-32dc0cb1b5ae895d237c7118ccaeb084715934fd.zip | |
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')
| -rw-r--r-- | test/lisp/replace-tests.el | 20 |
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: | |||
| 380 | (should (string= "211" (replace-tests--query-replace-undo))) | 380 | (should (string= "211" (replace-tests--query-replace-undo))) |
| 381 | (should (string= "211" (replace-tests--query-replace-undo 'comma)))) | 381 | (should (string= "211" (replace-tests--query-replace-undo 'comma)))) |
| 382 | 382 | ||
| 383 | (ert-deftest query-replace-undo-bug31073 () | ||
| 384 | "Test for https://debbugs.gnu.org/31073 ." | ||
| 385 | (let ((text "aaa aaa") | ||
| 386 | (count 0)) | ||
| 387 | (with-temp-buffer | ||
| 388 | (insert text) | ||
| 389 | (goto-char 1) | ||
| 390 | (cl-letf (((symbol-function 'read-event) | ||
| 391 | (lambda (&rest args) | ||
| 392 | (cl-incf count) | ||
| 393 | (let ((val (pcase count | ||
| 394 | ((or 1 2 3) ?\s) ; replace current and go next | ||
| 395 | (4 ?U) ; undo-all | ||
| 396 | (_ ?q)))) ; exit | ||
| 397 | val)))) | ||
| 398 | (perform-replace "a" "B" t nil nil)) | ||
| 399 | ;; After undo text must be the same. | ||
| 400 | (should (string= text (buffer-string)))))) | ||
| 401 | |||
| 402 | |||
| 383 | ;;; replace-tests.el ends here | 403 | ;;; replace-tests.el ends here |