[PR #10780] [MERGED] Move Pane to Tab (GH7075) #28234

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10780
Author: @Rosefield
Created: 7/24/2021
Status: Merged
Merged: 8/12/2021
Merged by: @undefined

Base: mainHead: feature/gh7075-move-pane-to-tab


📝 Commits (10+)

  • 0fb4b38 first very-much-not-working pass. Need to figure out how to manage all of the vestigial event handlers when we switch which tab owns a pane.
  • 4adfdee GH7075 Move Pane to Tab
  • e33b7aa Remove control event handlers when pane is detached. Make sure event handlers are removed when a tab gets closed as well. Try to keep active state updated when detaching
  • 64346fb Appease the spelling bot
  • d66d02e Flesh out comments on new methods. run code formatter
  • b8e95e3 Fix typos
  • 3bb24b2 Anticipate some code review refactoring. Make sure that we clean up extra closed handlers if we are moving the root element from a tab. Make sure that we preserve the ids when we attach a child from another tab.
  • 4077160 Fix duplicated comment. Only say we handled an action if we actually moved a pane
  • a7d7aec box the event token so that we can pass a reference to it to the event handler.
  • e7a9d21 Merge remote-tracking branch 'origin/main' into feature/gh7075-move-pane-to-tab

📊 Changes

22 files changed (+805 additions, -218 deletions)

View changed files

📝 .github/actions/spelling/allow/apis.txt (+1 -0)
📝 doc/cascadia/profiles.schema.json (+22 -3)
📝 src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp (+15 -20)
📝 src/cascadia/LocalTests_TerminalApp/TabTests.cpp (+10 -10)
📝 src/cascadia/TerminalApp/AppActionHandlers.cpp (+17 -3)
📝 src/cascadia/TerminalApp/AppCommandlineArgs.cpp (+50 -13)
📝 src/cascadia/TerminalApp/AppCommandlineArgs.h (+4 -1)
📝 src/cascadia/TerminalApp/Pane.cpp (+98 -33)
📝 src/cascadia/TerminalApp/Pane.h (+38 -3)
📝 src/cascadia/TerminalApp/Resources/en-US/Resources.resw (+12 -6)
📝 src/cascadia/TerminalApp/TabManagement.cpp (+70 -46)
📝 src/cascadia/TerminalApp/TerminalPage.cpp (+64 -11)
📝 src/cascadia/TerminalApp/TerminalPage.h (+6 -2)
📝 src/cascadia/TerminalApp/TerminalTab.cpp (+267 -39)
📝 src/cascadia/TerminalApp/TerminalTab.h (+25 -5)
📝 src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp (+2 -0)
📝 src/cascadia/TerminalSettingsModel/ActionArgs.cpp (+11 -3)
📝 src/cascadia/TerminalSettingsModel/ActionArgs.h (+60 -7)
📝 src/cascadia/TerminalSettingsModel/ActionArgs.idl (+8 -2)
📝 src/cascadia/TerminalSettingsModel/AllShortcutActions.h (+2 -0)

...and 2 more files

📄 Description

Summary of the Pull Request

Add functionality to move a pane to another tab. If the tab index is greater than the number of current tabs a new tab will be created with the pane as its root. Similarly, if the last pane on a tab is moved to another tab, the original tab will be closed.

This is largely complete, but I know that I'm messing around with things that I am unfamiliar with, and would like to avoid footguns where possible.

References

#4587

PR Checklist

  • Closes Run another command prompt from the Windows terminal (#7075)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated.
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

Things done:

  • Moving a pane to a new tab appears to work. Moving a pane to an existing tab mostly works. Moving a pane back to its original tab appears to work.
  • Set up {Attach,Detach}Pane methods to add or remove a pane from a pane. Detach is slightly different than Close in that we want to persist the tree structure and terminal controls.
  • Add Detached event on a pane that can be subscribed to to remove other event handlers if desired.
  • Added simple WalkTree abstraction for one-off recursion use cases that calls a provided function on each pane in order (and optionally terminates early).
  • Fixed an in-prod bug with closing panes. Specifically, if you have a tree (1; 2 3) and close the 1 pane, then 3 will lose its borders because of these lines clearing the border on both children https://github.com/microsoft/terminal/blob/main/src/cascadia/TerminalApp/Pane.cpp#L1197-L1201 .

To do:

  • Right now I have TerminalTab as a friend class of Pane so I can access some extra properties in my WalkTree callbacks, but there is probably a better choice for the abstraction boundary.

Next Steps:

  • In a future PR Drag & Drop handlers could be added that utilize the Attach/Detach infrastructure to provide a better UI.
  • Similarly once this is working, it should be possible to convert an entire tab into a pane on an existing tab (Tab::DetachRoot on original tab followed by Tab::AttachPane on the target tab).
  • Its been 10 years, I just really want to use concepts already.

Validation Steps Performed

Manual testing by creating pane(s), and moving them between tabs and creating new tabs and destroying tabs by moving the last remaining pane.


🔄 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/10780 **Author:** [@Rosefield](https://github.com/Rosefield) **Created:** 7/24/2021 **Status:** ✅ Merged **Merged:** 8/12/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `feature/gh7075-move-pane-to-tab` --- ### 📝 Commits (10+) - [`0fb4b38`](https://github.com/microsoft/terminal/commit/0fb4b381e7fe976b83a0a70f69610361db547ce1) first very-much-not-working pass. Need to figure out how to manage all of the vestigial event handlers when we switch which tab owns a pane. - [`4adfdee`](https://github.com/microsoft/terminal/commit/4adfdeead1cfc778d64303556fa1d0cd75b9a399) GH7075 Move Pane to Tab - [`e33b7aa`](https://github.com/microsoft/terminal/commit/e33b7aa0c5b377cb40e4b36e245140942fa86163) Remove control event handlers when pane is detached. Make sure event handlers are removed when a tab gets closed as well. Try to keep active state updated when detaching - [`64346fb`](https://github.com/microsoft/terminal/commit/64346fb6f591a2f503ca4de7d02a77f6d7e6a2da) Appease the spelling bot - [`d66d02e`](https://github.com/microsoft/terminal/commit/d66d02ef7fa40c3b5fd4805218b493b3a4cb25d3) Flesh out comments on new methods. run code formatter - [`b8e95e3`](https://github.com/microsoft/terminal/commit/b8e95e35d932a17f555158a565af693950cce32c) Fix typos - [`3bb24b2`](https://github.com/microsoft/terminal/commit/3bb24b206bd53c0797796dd2955782b44c39147e) Anticipate some code review refactoring. Make sure that we clean up extra closed handlers if we are moving the root element from a tab. Make sure that we preserve the ids when we attach a child from another tab. - [`4077160`](https://github.com/microsoft/terminal/commit/4077160e49dea4bb70ecb458064d5555b27a6015) Fix duplicated comment. Only say we handled an action if we actually moved a pane - [`a7d7aec`](https://github.com/microsoft/terminal/commit/a7d7aecbba78f13551728084c678703581912da5) box the event token so that we can pass a reference to it to the event handler. - [`e7a9d21`](https://github.com/microsoft/terminal/commit/e7a9d21bcaafaaa0e6327d3d939dbb303dd57738) Merge remote-tracking branch 'origin/main' into feature/gh7075-move-pane-to-tab ### 📊 Changes **22 files changed** (+805 additions, -218 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/allow/apis.txt` (+1 -0) 📝 `doc/cascadia/profiles.schema.json` (+22 -3) 📝 `src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp` (+15 -20) 📝 `src/cascadia/LocalTests_TerminalApp/TabTests.cpp` (+10 -10) 📝 `src/cascadia/TerminalApp/AppActionHandlers.cpp` (+17 -3) 📝 `src/cascadia/TerminalApp/AppCommandlineArgs.cpp` (+50 -13) 📝 `src/cascadia/TerminalApp/AppCommandlineArgs.h` (+4 -1) 📝 `src/cascadia/TerminalApp/Pane.cpp` (+98 -33) 📝 `src/cascadia/TerminalApp/Pane.h` (+38 -3) 📝 `src/cascadia/TerminalApp/Resources/en-US/Resources.resw` (+12 -6) 📝 `src/cascadia/TerminalApp/TabManagement.cpp` (+70 -46) 📝 `src/cascadia/TerminalApp/TerminalPage.cpp` (+64 -11) 📝 `src/cascadia/TerminalApp/TerminalPage.h` (+6 -2) 📝 `src/cascadia/TerminalApp/TerminalTab.cpp` (+267 -39) 📝 `src/cascadia/TerminalApp/TerminalTab.h` (+25 -5) 📝 `src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp` (+2 -0) 📝 `src/cascadia/TerminalSettingsModel/ActionArgs.cpp` (+11 -3) 📝 `src/cascadia/TerminalSettingsModel/ActionArgs.h` (+60 -7) 📝 `src/cascadia/TerminalSettingsModel/ActionArgs.idl` (+8 -2) 📝 `src/cascadia/TerminalSettingsModel/AllShortcutActions.h` (+2 -0) _...and 2 more files_ </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Add functionality to move a pane to another tab. If the tab index is greater than the number of current tabs a new tab will be created with the pane as its root. Similarly, if the last pane on a tab is moved to another tab, the original tab will be closed. This is largely complete, but I know that I'm messing around with things that I am unfamiliar with, and would like to avoid footguns where possible. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References #4587 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #7075 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [x] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [x] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments Things done: - Moving a pane to a new tab appears to work. Moving a pane to an existing tab mostly works. Moving a pane back to its original tab appears to work. - Set up {Attach,Detach}Pane methods to add or remove a pane from a pane. Detach is slightly different than Close in that we want to persist the tree structure and terminal controls. - Add `Detached` event on a pane that can be subscribed to to remove other event handlers if desired. - Added simple WalkTree abstraction for one-off recursion use cases that calls a provided function on each pane in order (and optionally terminates early). - Fixed an in-prod bug with closing panes. Specifically, if you have a tree (1; 2 3) and close the 1 pane, then 3 will lose its borders because of these lines clearing the border on both children https://github.com/microsoft/terminal/blob/main/src/cascadia/TerminalApp/Pane.cpp#L1197-L1201 . To do: - Right now I have `TerminalTab` as a friend class of `Pane` so I can access some extra properties in my `WalkTree` callbacks, but there is probably a better choice for the abstraction boundary. Next Steps: - In a future PR Drag & Drop handlers could be added that utilize the Attach/Detach infrastructure to provide a better UI. - Similarly once this is working, it should be possible to convert an entire tab into a pane on an existing tab (Tab::DetachRoot on original tab followed by Tab::AttachPane on the target tab). - Its been 10 years, I just really want to use concepts already. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Manual testing by creating pane(s), and moving them between tabs and creating new tabs and destroying tabs by moving the last remaining pane. --- <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:27:11 +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#28234