diff options
| author | Tino Calancha <tino.calancha@gmail.com> | 2018-06-03 23:28:24 +0900 |
|---|---|---|
| committer | Tino Calancha <tino.calancha@gmail.com> | 2018-06-03 23:28:24 +0900 |
| commit | 031004e81b1507c4594ae253faaafcda31f253c8 (patch) | |
| tree | 7f3c92e2169d93ee3f74facf5a4a24f8db6e1307 /test/lisp/replace-tests.el | |
| parent | 50c0624b2aecb9668505eb2cea3f30aecbf6d1ec (diff) | |
| download | emacs-031004e81b1507c4594ae253faaafcda31f253c8.tar.gz | |
Backport: Fix corner case in query-replace-regexp undo
This commit fixes Bug#31492.
* lisp/replace.el (replace-match-maybe-edit): Preserve match data.
* test/lisp/replace-tests.el (query-replace-undo-bug31492): Add test.
(cherry picked from commit bab73230d1be1fe394b7269c1365ef6fb1a5d9b3)
Diffstat (limited to 'test/lisp/replace-tests.el')
| -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 40a1a31cf7c..40ee838e679 100644 --- a/test/lisp/replace-tests.el +++ b/test/lisp/replace-tests.el @@ -399,5 +399,25 @@ Each element has the format: ;; After undo text must be the same. (should (string= text (buffer-string)))))) +(ert-deftest query-replace-undo-bug31492 () + "Test for https://debbugs.gnu.org/31492 ." + (let ((text "a\nb\nc\n") + (count 0) + (inhibit-message t)) + (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) ?\s) ; replace current and go next + (3 ?U) ; undo-all + (_ ?q)))) ; exit + val)))) + (perform-replace "^\\|\b\\|$" "foo" t t nil)) + ;; After undo text must be the same. + (should (string= text (buffer-string)))))) + ;;; replace-tests.el ends here |
