Subject: bug#56522: 28.1.50; Mismatch data after replace undo

From: Juri Linkov <[email-masked]>
Date: Tue, 12 Jul 2022 20:46:37 +0300

X-Debbugs-CC: Tino Calancha <[email-masked]>

Something is wrong with next-replacement that is not updated
after Undo in perform-replace.  The minimal test case:

1. add to a buffer such text:

   a! b? .

2. then invoke query-replace-regexp with such regexp:

   Query replace regexp: \([!?]\) → <\1>

3. then type:

   y u n y  (i.e. yes, undo, no, yes - that should undo,
             leave the first match unchanged, and replace the second)

4. observe the result:

   a! b<!> .

i.e. the match data in next-replacement for the second match
comes from the first match.