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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/14060
Author: @sotteson1
Created: 9/22/2022
Status: Merged
Merged: 12/8/2022
Merged by: @undefined

Base: mainHead: ctrl-d-support


📝 Commits (10+)

  • 21cf69d Add support to close a failed pain with ctrl+D
  • 5606291 Implement ctrl+D as an event that Pane watches
  • 6de50b0 Fix a couple of typos from the last cleanup
  • d902eb8 Fix formatting issues
  • 092957f Add support for restarting terminal with Enter
  • 27096e6 Add comment to line setting PSEUDOCONSOLE_INHERIT_CURSOR
  • ec7dfc5 Keep track of rows/cols in connection even when disconnected
  • 82b6876 Fix analysis error
  • 62888a5 Add comment to help with localization.
  • 899f009 Update message to use Ctrl+D instead of ^D

📊 Changes

12 files changed (+106 additions, -19 deletions)

View changed files

📝 .github/actions/spelling/allow/allow.txt (+2 -0)
📝 src/cascadia/TerminalApp/Pane.cpp (+28 -1)
📝 src/cascadia/TerminalApp/Pane.h (+2 -0)
📝 src/cascadia/TerminalConnection/ConnectionStateHolder.h (+8 -0)
📝 src/cascadia/TerminalConnection/ConptyConnection.cpp (+36 -16)
📝 src/cascadia/TerminalConnection/ConptyConnection.h (+2 -2)
📝 src/cascadia/TerminalConnection/Resources/en-US/Resources.resw (+4 -0)
📝 src/cascadia/TerminalControl/ControlCore.cpp (+19 -0)
📝 src/cascadia/TerminalControl/ControlCore.h (+1 -0)
📝 src/cascadia/TerminalControl/ControlCore.idl (+1 -0)
📝 src/cascadia/TerminalControl/TermControl.h (+1 -0)
📝 src/cascadia/TerminalControl/TermControl.idl (+2 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/14060 **Author:** [@sotteson1](https://github.com/sotteson1) **Created:** 9/22/2022 **Status:** ✅ Merged **Merged:** 12/8/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `ctrl-d-support` --- ### 📝 Commits (10+) - [`21cf69d`](https://github.com/microsoft/terminal/commit/21cf69d7413f64fa9625e2665654e569c602574a) Add support to close a failed pain with ctrl+D - [`5606291`](https://github.com/microsoft/terminal/commit/560629114c2ac8e8dd40ba3689f5d7137fab767f) Implement ctrl+D as an event that Pane watches - [`6de50b0`](https://github.com/microsoft/terminal/commit/6de50b036abe99892ca0401c740b1c4b4ab4735e) Fix a couple of typos from the last cleanup - [`d902eb8`](https://github.com/microsoft/terminal/commit/d902eb8477d51153474d80984853039b6157cac8) Fix formatting issues - [`092957f`](https://github.com/microsoft/terminal/commit/092957f937e85b589324a657d100ec40cf76058a) Add support for restarting terminal with Enter - [`27096e6`](https://github.com/microsoft/terminal/commit/27096e619f0e476aacca8470e5953e3a46910e9c) Add comment to line setting PSEUDOCONSOLE_INHERIT_CURSOR - [`ec7dfc5`](https://github.com/microsoft/terminal/commit/ec7dfc5525a753d9ec75be4343683893172ab19d) Keep track of rows/cols in connection even when disconnected - [`82b6876`](https://github.com/microsoft/terminal/commit/82b687682f83ff01af922dbd13777a2045588906) Fix analysis error - [`62888a5`](https://github.com/microsoft/terminal/commit/62888a5a0f2ccda00b53e52e96537fd67213e4ab) Add comment to help with localization. - [`899f009`](https://github.com/microsoft/terminal/commit/899f00910e139e61774e826988db08580059a7d6) Update message to use Ctrl+D instead of ^D ### 📊 Changes **12 files changed** (+106 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/allow/allow.txt` (+2 -0) 📝 `src/cascadia/TerminalApp/Pane.cpp` (+28 -1) 📝 `src/cascadia/TerminalApp/Pane.h` (+2 -0) 📝 `src/cascadia/TerminalConnection/ConnectionStateHolder.h` (+8 -0) 📝 `src/cascadia/TerminalConnection/ConptyConnection.cpp` (+36 -16) 📝 `src/cascadia/TerminalConnection/ConptyConnection.h` (+2 -2) 📝 `src/cascadia/TerminalConnection/Resources/en-US/Resources.resw` (+4 -0) 📝 `src/cascadia/TerminalControl/ControlCore.cpp` (+19 -0) 📝 `src/cascadia/TerminalControl/ControlCore.h` (+1 -0) 📝 `src/cascadia/TerminalControl/ControlCore.idl` (+1 -0) 📝 `src/cascadia/TerminalControl/TermControl.h` (+1 -0) 📝 `src/cascadia/TerminalControl/TermControl.idl` (+2 -0) </details> ### 📄 Description 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:37:33 +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#29906