[PR #14060] When the terminal has exited, ctrl+D to close pane, Enter to restart terminal #29911

Open
opened 2026-01-31 09:37:34 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/14060

State: closed
Merged: Yes


When a terminal process exits (successful or not) and the profile isn't
set to automatically close the pane, a new message is displayed:

You can now close this terminal with ^D or Enter to restart.

Ctrl+D then is able to close the pane and Enter restarts it.

I originally tried to do this at the ConptyConnection layer by changing
the connection state from Failed to Closed, but then that didn't work
for the case where the process exited successfully but the profile isn't
set to exit automatically. So, I added an event to
ControlCore/TermControl that Pane watches. ControlCore watches to see if
the input is Ctrl+D (0x4) and if the connection is closed or failed, and
then raises the event so that Pane can close itself. As it turned out, I
think this is the better place to have the logic to watch for the Ctrl+D
key. Doing it at the ConptyConnection layer meant I had to parse out the
key from the escaped text passed to ConptyConnection::WriteInput.

Validation Steps Performed

Tried adding lots of panes and then killing the processes outside of
Terminal. Each showed the new message and I could close them with Ctrl+D
or restart them with Enter. Also set a profile to never close
automatically to make sure Ctrl+D would work when a process exits
successfully.

Closes #12849
Closes #11570
Closes #4379

**Original Pull Request:** https://github.com/microsoft/terminal/pull/14060 **State:** closed **Merged:** Yes --- When a terminal process exits (successful or not) and the profile isn't set to automatically close the pane, a new message is displayed: You can now close this terminal with ^D or Enter to restart. Ctrl+D then is able to close the pane and Enter restarts it. I originally tried to do this at the ConptyConnection layer by changing the connection state from Failed to Closed, but then that didn't work for the case where the process exited successfully but the profile isn't set to exit automatically. So, I added an event to ControlCore/TermControl that Pane watches. ControlCore watches to see if the input is Ctrl+D (0x4) and if the connection is closed or failed, and then raises the event so that Pane can close itself. As it turned out, I think this is the better place to have the logic to watch for the Ctrl+D key. Doing it at the ConptyConnection layer meant I had to parse out the key from the escaped text passed to ConptyConnection::WriteInput. ## Validation Steps Performed Tried adding lots of panes and then killing the processes outside of Terminal. Each showed the new message and I could close them with Ctrl+D or restart them with Enter. Also set a profile to never close automatically to make sure Ctrl+D would work when a process exits successfully. Closes #12849 Closes #11570 Closes #4379
claunia added the pull-request label 2026-01-31 09:37:34 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29911