Add close pane to the tab context menu (when there are multiple panes) #18020

Closed
opened 2026-01-31 06:01:27 +00:00 by claunia · 9 comments
Owner

Originally created by @vertigo220 on GitHub (Jul 23, 2022).

Description of the new feature/enhancement

Once a tab is split, there's no way to return it to normal, meaning either having to continue working in half the space or starting a new tab and losing everything from the current one. It should allow for either closing one half or splitting them into two tabs.

Proposed technical implementation details (optional)

Originally created by @vertigo220 on GitHub (Jul 23, 2022). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> Once a tab is split, there's no way to return it to normal, meaning either having to continue working in half the space or starting a new tab and losing everything from the current one. It should allow for either closing one half or splitting them into two tabs. # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@zadjii-msft commented on GitHub (Jul 23, 2022):

You mean like the closePane action/? Or maybe moving panes to their own tabs? Or heck even zooming a pane, to make it take the full size of the tab again?

@zadjii-msft commented on GitHub (Jul 23, 2022): You mean like the [`closePane` action](https://docs.microsoft.com/en-us/windows/terminal/panes#closing-a-pane)/? Or maybe [moving panes to their own tabs](https://docs.microsoft.com/en-us/windows/terminal/panes#moving-panes)? Or heck even [zooming a pane](https://docs.microsoft.com/en-us/windows/terminal/panes#zooming-a-pane), to make it take the full size of the tab again?
Author
Owner

@vertigo220 commented on GitHub (Jul 24, 2022):

I guess all three options would be nice, though I was mainly talking about the first. I didn't realize it was even an option since I didn't think to check the actions, and it's something I feel should be available via a menu and not just a shortcut, both to make it more obvious that it is an option, and to make it easier to do without having to remember the shortcut, especially since it's likely not something most would use very often.

I see three ways of handling this. The cleanest, most space-efficient, and probably most obvious would be to add the actions to the tab's right-click menu, e.g. "Close active pane," "Move active pane to new tab," "Make active pane full-size" (zoom it), and "Close all non-active panes" (though this one could be dangerous and would probably benefit from a confirmation dialog). Then whichever pane is active when right-clicking the tab and selecting one of the options would be the one acted on.

The second possibility would be to add a small title bar to each pane that could be right-clicked, which would bring up a menu with the previous options, minus the word active or replacing it with "other" in the case of closing the other panes, of course.

The third option would be to add a few small buttons at the top-right of each pane, an x to close it, a square to maximize it or double square to restore it, and something like a square with an arrow for separating it out into a new tab.

@vertigo220 commented on GitHub (Jul 24, 2022): I guess all three options would be nice, though I was mainly talking about the first. I didn't realize it was even an option since I didn't think to check the actions, and it's something I feel should be available via a menu and not just a shortcut, both to make it more obvious that it _is_ an option, and to make it easier to do without having to remember the shortcut, especially since it's likely not something most would use very often. I see three ways of handling this. The cleanest, most space-efficient, and probably most obvious would be to add the actions to the tab's right-click menu, e.g. "Close active pane," "Move active pane to new tab," "Make active pane full-size" (zoom it), and "Close all non-active panes" (though this one could be dangerous and would probably benefit from a confirmation dialog). Then whichever pane is active when right-clicking the tab and selecting one of the options would be the one acted on. The second possibility would be to add a small title bar to each pane that could be right-clicked, which would bring up a menu with the previous options, minus the word active or replacing it with "other" in the case of closing the other panes, of course. The third option would be to add a few small buttons at the top-right of each pane, an x to close it, a square to maximize it or double square to restore it, and something like a square with an arrow for separating it out into a new tab.
Author
Owner

@zadjii-msft commented on GitHub (Jul 29, 2022):

FWIW, the general pattern the Terminal uses is that all the actions for the Terminal are in the Command Palette. We don't have a whole lot of UI space, so the command palette is a great way for us to have LOTS of actions while also making sure most menus aren't excessively cluttered. That being said

@zadjii-msft commented on GitHub (Jul 29, 2022): FWIW, the general pattern the Terminal uses is that all the actions for the Terminal are in the Command Palette. We don't have a whole lot of UI space, so the command palette is a great way for us to have LOTS of actions while also making sure most menus aren't excessively cluttered. That being said * Sure, okay, we can use this to track "Add close pane to the tab context menu (when there are multiple panes)" * see: #4717 * This will probably also fit under the same feature set as above
Author
Owner

@rismoney commented on GitHub (Nov 17, 2022):

how is this on the backlog? How do people even use this half-baked capability?

@rismoney commented on GitHub (Nov 17, 2022): how is this on the backlog? How do people even use this half-baked capability?
Author
Owner

@zadjii-msft commented on GitHub (Nov 17, 2022):

@rismoney Probably because most people just close panes with the keyboard (ctrl+shift+w), or the Command Palette ctrl+shift+p. If you're passionate about the feature, I can try and help provide a roadmap of where the code changes would need to go.

@zadjii-msft commented on GitHub (Nov 17, 2022): @rismoney Probably because most people just close panes with the keyboard (<kbd>ctrl+shift+w</kbd>), or the Command Palette <kbd>ctrl+shift+p</kbd>. If you're passionate about the feature, I can try and help provide a roadmap of where the code changes would need to go.
Author
Owner

@rismoney commented on GitHub (Nov 28, 2022):

keyboard shortcuts ftw!

@rismoney commented on GitHub (Nov 28, 2022): keyboard shortcuts ftw!
Author
Owner

@Smeyer025 commented on GitHub (Mar 20, 2023):

@rismoney Probably because most people just close panes with the keyboard (ctrl+shift+w), or the Command Palette ctrl+shift+p. If you're passionate about the feature, I can try and help provide a roadmap of where the code changes would need to go.

@zadjii-msft I don't know if the offer is still on the table (or open to outside help), but I would love to take a crack at this and a roadmap would be extremely helpful!

@Smeyer025 commented on GitHub (Mar 20, 2023): > @rismoney Probably because most people just close panes with the keyboard (ctrl+shift+w), or the Command Palette ctrl+shift+p. If you're passionate about the feature, I can try and help provide a roadmap of where the code changes would need to go. @zadjii-msft I don't know if the offer is still on the table (or open to outside help), but I would love to take a crack at this and a roadmap would be extremely helpful!
Author
Owner

@zadjii-msft commented on GitHub (Mar 20, 2023):

Of course!

Note

Walkthrough

  • I'd start by taking a look at TerminalTab::_CreateContextMenu, in TerminalTab.cpp. That's what we use for building all the other context menu entries for the tabs, so that's a good place to insert a new one.
  • I'd stash the Controls::MenuFlyoutItem that you make for ClosePane into the TerminalTab itself as a member. That way, we can use that member to toggle the visibility when the number of panes in the tab changes.
  • I'd start by setting the item to be Visibility(Collapsed), so that it's not initially visible.
  • TerminalTab::SplitPane is where new splits get added, so that would be a good place to change the Visibility to Visible
  • in TerminalTab::_AttachEventHandlersToPane, we add a pane->Closed callback, which we could use to set the Visibility back to Collapsed if there's only one pane in the tree.

Lemme know if you need any more help!

@zadjii-msft commented on GitHub (Mar 20, 2023): Of course! > **Note** > ## Walkthrough * I'd start by taking a look at `TerminalTab::_CreateContextMenu`, in `TerminalTab.cpp`. That's what we use for building all the other context menu entries for the tabs, so that's a good place to insert a new one. * I'd stash the `Controls::MenuFlyoutItem` that you make for `ClosePane` into the `TerminalTab` itself as a member. That way, we can use that member to toggle the visibility when the number of panes in the tab changes. * I'd start by setting the item to be `Visibility(Collapsed)`, so that it's not initially visible. * `TerminalTab::SplitPane` is where new splits get added, so that would be a good place to change the `Visibility` to `Visible` * in `TerminalTab::_AttachEventHandlersToPane`, we add a `pane->Closed` callback, which we could use to set the `Visibility` back to `Collapsed` if there's only one pane in the tree. <hr> Lemme know if you need any more help!
Author
Owner

@joadoumie commented on GitHub (Apr 18, 2023):

Image

I decided to take a crack at this one and I think I have the functionality working. What should we use for the icon in the context menu?

@joadoumie commented on GitHub (Apr 18, 2023): ![Image](https://user-images.githubusercontent.com/98557455/232645653-d1a09c90-5c90-4c59-ae40-52860ec73dee.gif) I decided to take a crack at this one and I think I have the functionality working. What should we use for the icon in the context menu?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18020