Repository: microsoft/terminal
File: src/cascadia/TerminalApp/Pane.cpp (C++)

Code before:
        _FocusFirstChild();
        e.Handled(true);
    });
}

// Method Description:
// - Extract the terminal settings from the current (leaf) pane's control
//   to be used to create an equivalent control
// Arguments:
// - <none>
// Return Value:
// - Arguments appropriate for a SplitPane or NewTab action
NewTerminalArgs Pane::GetTerminalArgsForPane() const
{
    // Leaves are the only things that have controls
    assert(_IsLeaf());

    NewTerminalArgs args{};
    auto controlSettings = _control.Settings().as<TerminalSettings>();

    args.Profile(controlSettings.ProfileName());
    // If we know the user's working directory use it instead of the profile.
    if (!_control.WorkingDirectory().empty())
    {
        args.StartingDirectory(_control.WorkingDirectory());
    }
    else
    {
        args.StartingDirectory(controlSettings.StartingDirectory());
    }
    args.TabTitle(controlSettings.StartingTitle());
    args.Commandline(controlSettings.Commandline());
    args.SuppressApplicationTitle(controlSettings.SuppressApplicationTitle());
    if (controlSettings.TabColor() || controlSettings.StartingTabColor())
    {
        til::color c;
        // StartingTabColor is prioritized over other colors
        if (const auto color = controlSettings.StartingTabColor())
        {
            c = til::color(color.Value());
        }
        else
        {
            c = til::color(controlSettings.TabColor().Value());
        }

        args.TabColor(winrt::Windows::Foundation::IReference<winrt::Windows::UI::Color>(c));
    }

    if (controlSettings.AppliedColorScheme())
    {

Review comment (suggestion):
You can prevent the double-COM-call with
```suggestion
    if (const auto path = _control.WorkingDirectory(); !path.empty())
    {
        args.StartingDirectory(path);
    }
```

I love the syntax... it strongly reminds me of Go.

Code after:
        _FocusFirstChild();
        e.Handled(true);
    });
}

// Method Description:
// - Extract the terminal settings from the current (leaf) pane's control
//   to be used to create an equivalent control
// Arguments:
// - <none>
// Return Value:
// - Arguments appropriate for a SplitPane or NewTab action
NewTerminalArgs Pane::GetTerminalArgsForPane() const
{
    // Leaves are the only things that have controls
    assert(_IsLeaf());

    NewTerminalArgs args{};
    auto controlSettings = _control.Settings().as<TerminalSettings>();

    args.Profile(controlSettings.ProfileName());
    // If we know the user's working directory use it instead of the profile.
    if (const auto dir = _control.WorkingDirectory(); !dir.empty())
    {
        args.StartingDirectory(dir);
    }
    else
    {
        args.StartingDirectory(controlSettings.StartingDirectory());
    }
    args.TabTitle(controlSettings.StartingTitle());
    args.Commandline(controlSettings.Commandline());
    args.SuppressApplicationTitle(controlSettings.SuppressApplicationTitle());
    if (controlSettings.TabColor() || controlSettings.StartingTabColor())
    {
        til::color c;
        // StartingTabColor is prioritized over other colors
        if (const auto color = controlSettings.StartingTabColor())
        {
            c = til::color(color.Value());
        }
        else
        {
            c = til::color(controlSettings.TabColor().Value());
        }

        args.TabColor(winrt::Windows::Foundation::IReference<winrt::Windows::UI::Color>(c));
    }

    if (controlSettings.AppliedColorScheme())
    {