Subject: Re: bug#79125: quit-window fails to restore window height in a scenario of buffer reuse

From: martin rudalics <[email-masked]>
Date: Fri, 1 Aug 2025 10:53:41 +0200

> I've tried it out, and it doesn't seem to fix the original scenario.

Right. The code should be

(defun vc-shrink-buffer-window (&optional buffer)
   "Call `shrink-window-if-larger-than-buffer' only when BUFFER is visible.
BUFFER defaults to the current buffer."
   (let ((window (get-buffer-window buffer t)))
     (when window
       (let* ((quit-restore (window-parameter window 'quit-restore))
	     (quad (and quit-restore (nth 1 quit-restore))))
	(when (or (not quit-restore) (not (listp quad))
		  (eq (window-buffer window) (nth 0 quad)))
	  (shrink-window-if-larger-than-buffer window))))))

 > If the goal was to implement your explanation from the other subthread:
 >
 >  > In the following cases:
 >  >
 >  > - The window is new.
 >  >
 >  > - The window was already in use for this buffer.
 >
 > ...then it seems fail because it resizes an existing window showing a different buffer. Probably because the value of QUAD is 'window', in my testing.

I tried your original scenario and it does not resize windows any more.
C-x v g followed by C-x 1 followed by l or d should work as before.

martin