Subject: quit-window fails to restore window height in a scenario of buffer reuse

From: Dmitry Gutov <[email-masked]>
Date: Wed, 30 Jul 2025 04:59:39 +0300

X-Debbugs-CC: [email-masked], [email-masked]

Just to preface, it's not a regression against a recent version of 
Emacs. But seeing as we've done some changes in this area lately, such 
as bug#59862, he's a scenario to consider.

1. cd path/to/emacs && src/emacs -Q
2. Visit admin/authors.el (just an example with known vc log message)
3. C-x v g - it creates an even window split, and shows the buffer below.
4. Press 'd' - that shows the diff buffer in the top window.
5. C-x o, to switch to the bottom window again.
6. Move to the second line, press 'l' - that shows vc-change-log buffer 
in the top window, resizing it to fit (shrinking the height to 5 lines).
7. Press 'd'. That shows the vc-diff buffer in the same window, keeping 
the short height. Apparently (*) because the same buffer - though with 
different contents - has been displayed in this window just recently?
8. Press 'q'. The top window shows vc-change-log buffer again, height 
unchanged.
9. Press 'q' again. The top window switches to authors.el but the 
previous height (before the vc-change-log buffer was displayed) is not 
restored, so it's still 5 lines tall. Maybe (**) because the current 
buffer is not the same as what was there before?

Now (*) and (**) are my guesses.

(*) is something that might be fixable in the specific command. But it 
uses 'pop-to-buffer', as is usual.

(**) if can be improved, would be more general change.

Does anybody agree that steps 7 and/or 9 behave suboptimally? Can that 
be improved?