Unify pane splitting and new tab creation #14953

Closed
opened 2026-01-31 04:24:08 +00:00 by claunia · 4 comments
Owner

Originally created by @DHowett on GitHub (Aug 23, 2021).

In my eyes, spawning a new tab is a special case of splitting a nonexistent window into one pane.

Right now, we have a lot of divergence between opening a tab (1) and opening a pane (2); in both cases we spawn a new control, but the way it gets propagated into the tree is vastly different. The same applies for duplicating an active pane; the code in pane splitting suggests that duplicating a pane keeps the working directory but a tab does not (!) (see 3) EDIT: No, we accounted for it. Double the code, double the places to look 😉

1

10992b77a0/src/cascadia/TerminalApp/TabManagement.cpp (L242-L272)

2

10992b77a0/src/cascadia/TerminalApp/TerminalPage.cpp (L1391-L1416)

Collapsed note 3

3

10992b77a0/src/cascadia/TerminalApp/TerminalPage.cpp (L1359-L1370)

Originally created by @DHowett on GitHub (Aug 23, 2021). In my eyes, spawning a new tab is a special case of splitting a nonexistent window into one pane. Right now, we have a lot of divergence between opening a tab (1) and opening a pane (2); in both cases we spawn a new control, but the way it gets propagated into the tree is vastly different. The same applies for duplicating an active pane; ~the code in pane splitting suggests that duplicating a pane keeps the working directory but a tab does not (!) (see 3)~ EDIT: No, we accounted for it. Double the code, double the places to look 😉 ### 1 https://github.com/microsoft/terminal/blob/10992b77a0aafdaf1166493df3d0c044bf8975ea/src/cascadia/TerminalApp/TabManagement.cpp#L242-L272 ### 2 https://github.com/microsoft/terminal/blob/10992b77a0aafdaf1166493df3d0c044bf8975ea/src/cascadia/TerminalApp/TerminalPage.cpp#L1391-L1416 <details> <summary>Collapsed note 3</summary> ### 3 https://github.com/microsoft/terminal/blob/10992b77a0aafdaf1166493df3d0c044bf8975ea/src/cascadia/TerminalApp/TerminalPage.cpp#L1359-L1370 </details>
Author
Owner

@DHowett commented on GitHub (Aug 23, 2021):

/cc @PankajBhojwani you did some of the work here to make control initialization uniform, but this is the "farther step" i was talking about. You don't need to do this; it's just an FYI. 😄

@DHowett commented on GitHub (Aug 23, 2021): /cc @PankajBhojwani you did some of the work here to make _control_ initialization uniform, but this is the "farther step" i was talking about. You don't need to do this; it's just an FYI. :smile:
Author
Owner

@PankajBhojwani commented on GitHub (Aug 23, 2021):

Ah I like this

@PankajBhojwani commented on GitHub (Aug 23, 2021): Ah I like this
Author
Owner

@zadjii-msft commented on GitHub (Aug 23, 2021):

I've meant to do this for so long. The TabManagement.cpp PR really highlighted how bad this one is

@zadjii-msft commented on GitHub (Aug 23, 2021): I've meant to do this for so long. The `TabManagement.cpp` PR really highlighted how bad this one is
Author
Owner

@Rosefield commented on GitHub (Aug 24, 2021):

The CreateNewTabFromPane function that I added as part of move pane to tab could probably be used for this. If you look at _SplitPane, you create the profile/control, then in one branch you do the PreCalculate* and then tab.SplitPane and on the other you just CreateNewTabFromPane. That should get you most of the way there, I think. Internally Pane::Split is effectively just auto pane = std::make_shared<Pane>; _Split(pane) so that could just be modified to take a pane directly instead of passing the control/profile down.

@Rosefield commented on GitHub (Aug 24, 2021): The `CreateNewTabFromPane` function that I added as part of move pane to tab could probably be used for this. If you look at `_SplitPane`, you create the profile/control, then in one branch you do the `PreCalculate*` and then `tab.SplitPane` and on the other you just `CreateNewTabFromPane`. That should get you most of the way there, I think. Internally `Pane::Split` is effectively just `auto pane = std::make_shared<Pane>; _Split(pane)` so that could just be modified to take a pane directly instead of passing the control/profile down.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14953