Subject: bug#58175: 29.0.50; M-x window-swap-states during an active mark leaves behind a region overlay

From: Eli Zaretskii <[email-masked]>
Date: Sun, 02 Oct 2022 19:50:13 +0300

> Cc: [email-masked]
> Date: Thu, 29 Sep 2022 22:19:34 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> > From: <[email-masked]>
> > Cc: [email-masked]
> > Date: Thu, 29 Sep 2022 21:17:56 +0200
> > 
> > >> 1. 'C-h e' to display *Messages* in a new window
> > >> 2. 'C-SPC C-n' to mark an active region
> > >> 3. 'M-x window-swap-states'
> > >> 4. 'C-g C-n' to deactivate the mark
> > >> 
> > >> Notice how the region overlay stays there.
> > >
> > > "There" where?
> > 
> > In the *GNU Emacs* buffer, where we have originally marked a region in
> > step 2.
> > 
> > > What did you expect to happen in the above scenario, and why?
> > 
> > I expect the overlay to disappear after deactivating the mark with 'C-g'
> > in step 4.
> 
> Ah!  Now it's clear what this issue is about.
> 
> The problem is that deactivate-mark doesn't work in this case, for
> some reason, and neither is setting mark-active to nil.

Looks like the internal-region-overlay window parameter, which is
important for correct workings of region-highlight, isn't copied
correctly to the other window as part of swapping state, because its
value ends up as "overlay N in no buffer", i.e. the overlay's buffer
is lost in transition.

Martin, Stefan: any suggestions or ideas?