terminal
terminal copied to clipboard
Window doesn't close when it's dragged WHILE a defterm app exits
Windows Terminal version
1.12.10733.0
Windows build number
10.0.22000.613
Other Software
No response
Steps to reproduce
- Create batch-file with
timeout /t 5 - Doubleclick batch file
- While timer is going down move the window until the timer ends with the mouse (It is not important, when you start moving the windows, it is important that you have it ON your mouse with a pressed key, when the timer ends)
- Try to close the windows with pressing a key or pressing the
X-Button in the right upper corner to close it
Expected Behavior
The window should close automatically after releasing the mouse (Or with pressing a key or the X-Button)
Actual Behavior
The window is NOT closing automatically, with pressing a key or with the X-Button.

https://user-images.githubusercontent.com/86119630/164326069-bd55d556-6c07-4f75-af06-e90b9ce69939.mp4
That's wild. Thanks for the great bug report! I wonder why moving the window while the last tab closes prevents the app from tearing down....
To work around, add a new tab and then you can close the window.
To work around, add a new tab and then you can close the window.
Yes I found this work around too.
Oh god this is so much worse in 1.15. It doesn't timeout at all, it instantly exits!
echo foo
@rem set /p id=Enter ID:
timeout /t 10
echo bar
exit 1234

~OH oh oh I bet this has to do with focus events. That's my guess - timeout will bail on input. Like, any input? That I'm not sure about. But I bet the regression between 1.12 when this was filed, and now (1.15/16/17) is the focus event stuff, and I bet eveything is immediately getting a focus event in the input queue right off the bat.~
I'll need to go inspect timeout's source to confirm. That's my hypothesis.
Notably, this doesn't repro the same if you actually "restart" the batch script, until you press a key:

I noticed this when I restored the Terminal from being quit, and this defterm window came back ~(presumably, without the focus event)~. This might be related to #13514
Okay, my hypothesis was wrong. Looks like timeout does filter FOCUS events out... even if it does have some other horrifying code in it.
I also reproduced it a few days ago by accident.
I'm gonna fork my above comments into a separate bug, cause there's multiple bits here with different tiers of badness.
Actually, this doesn't have anything to do with defterm at all. This repros pretty readily with sleep 3 ; exit 0 in powershell too.