Skip to content

Commit 558a396

Browse files
committed
Split Panes inherit tab color and title of active pane
Previously to this PR if you split a pane as suggested in #18930, the split pane will lose its custom title and will not have its custom color, with this PR it will keep as indicated
1 parent e332c67 commit 558a396

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

src/cascadia/TerminalApp/AppActionHandlers.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,25 @@ namespace winrt::TerminalApp::implementation
279279
return;
280280
}
281281

282-
const auto& duplicateFromTab{ realArgs.SplitMode() == SplitType::Duplicate ? _GetFocusedTab() : nullptr };
283-
284282
const auto& terminalTab{ _senderOrFocusedTab(sender) };
285-
286-
_SplitPane(terminalTab,
283+
const auto& duplicateFromTab { realArgs.SplitMode() == SplitType::Duplicate ? _GetFocusedTab() : nullptr };
284+
// The tab is not focused yet if we just created the tab, hacky workaround want to get feedback on if ive missed a edge cas ebefore cleaning up
285+
if (!duplicateFromTab && terminalTab.get())
286+
{
287+
_SplitPane(terminalTab,
288+
realArgs.SplitDirection(),
289+
// This is safe, we're already filtering so the value is (0, 1)
290+
realArgs.SplitSize(),
291+
_MakePane(realArgs.ContentArgs(), *terminalTab.get()));
292+
}
293+
else
294+
{
295+
_SplitPane(terminalTab,
287296
realArgs.SplitDirection(),
288297
// This is safe, we're already filtering so the value is (0, 1)
289298
realArgs.SplitSize(),
290299
_MakePane(realArgs.ContentArgs(), duplicateFromTab));
300+
}
291301
args.Handled(true);
292302
}
293303
}

src/cascadia/TerminalApp/TabManagement.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ namespace winrt::TerminalApp::implementation
8989

9090
// This call to _MakePane won't return nullptr, we already checked that
9191
// case above with the _maybeElevate call.
92+
// _MakePane
9293
_CreateNewTabFromPane(_MakePane(newContentArgs, nullptr));
9394
return S_OK;
9495
}

src/cascadia/TerminalApp/TerminalPage.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,6 +3285,19 @@ namespace winrt::TerminalApp::implementation
32853285
{
32863286
controlSettings.DefaultSettings().StartingDirectory(workingDirectory);
32873287
}
3288+
// Copy Title and Color of tab you split
3289+
controlSettings.DefaultSettings().StartingTitle(terminalTab->Title());
3290+
const auto color = terminalTab->GetTabColor();
3291+
if (color.has_value())
3292+
{
3293+
const auto& rawColor = color.value();
3294+
controlSettings.DefaultSettings().StartingTabColor(
3295+
winrt::Microsoft::Terminal::Core::Color{
3296+
rawColor.R,
3297+
rawColor.G,
3298+
rawColor.B,
3299+
rawColor.A });
3300+
}
32883301
}
32893302
}
32903303
if (!profile)

0 commit comments

Comments
 (0)