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

Code before:
        ShowSetAsDefaultInfoBar();
    }

    // Method Description;
    // - Checks if the current terminal window should load or save its layout information.
    // Arguments:
    // - settings: The settings to use as this may be called before the page is
    //   fully initialized.
    // Return Value:
    // - true if the ApplicationState should be used.
    bool TerminalPage::ShouldUsePersistedLayout(CascadiaSettings& settings) const
    {
        return Feature_PersistedWindowLayout::IsEnabled() &&
               settings.GlobalSettings().FirstWindowPreference() == FirstWindowPreference::PersistedWindowLayout;
    }

    // Method Description:
    // - This is a bit of trickiness: If we're running unelevated, and the user
    //   passed in only --elevate actions, the we don't _actually_ want to
    //   restore the layouts here. We're not _actually_ about to create the
    //   window. We're simply going to toss the commandlines
    // Arguments:
    // - <none>
    // Return Value:
    // - <none>
    bool TerminalPage::ShouldImmediatelyHandoffToElevated(CascadiaSettings& settings) const
    {
        if (!_startupActions || IsElevated())
        {
            // there arent startup actions, or we're elevated. In that case, go for it.
            return false;
        }

        // Check that there's at least one action that's not just an elevated newTab action.
        for (const auto& action : _startupActions)
        {
            NewTerminalArgs newTerminalArgs{ nullptr };

            if (action.Action() == ShortcutAction::NewTab)
            {
                const auto& args{ action.Args().try_as<NewTabArgs>() };
                if (args)
                {
                    newTerminalArgs = args.TerminalArgs();
                }
                else
                {
                    // This was a nt action that didn't have any args. The default
                    // profile may want to be elevated, so don't just early return.
                }
            }

Review comment (suggestion):
This doesn't seem to need a mutable reference to `settings`. Make it a const ref?
Same for the one below.

Code after:
        ShowSetAsDefaultInfoBar();
    }

    // Method Description;
    // - Checks if the current terminal window should load or save its layout information.
    // Arguments:
    // - settings: The settings to use as this may be called before the page is
    //   fully initialized.
    // Return Value:
    // - true if the ApplicationState should be used.
    bool TerminalPage::ShouldUsePersistedLayout(CascadiaSettings& settings) const
    {
        return Feature_PersistedWindowLayout::IsEnabled() &&
               settings.GlobalSettings().FirstWindowPreference() == FirstWindowPreference::PersistedWindowLayout;
    }

    // Method Description:
    // - This is a bit of trickiness: If we're running unelevated, and the user
    //   passed in only --elevate actions, the we don't _actually_ want to
    //   restore the layouts here. We're not _actually_ about to create the
    //   window. We're simply going to toss the commandlines
    // Arguments:
    // - <none>
    // Return Value:
    // - true if we're not elevated but all relevant pane-spawning actions are elevated
    bool TerminalPage::ShouldImmediatelyHandoffToElevated(const CascadiaSettings& settings) const
    {
        if (!_startupActions || IsElevated())
        {
            // there arent startup actions, or we're elevated. In that case, go for it.
            return false;
        }

        // Check that there's at least one action that's not just an elevated newTab action.
        for (const auto& action : _startupActions)
        {
            NewTerminalArgs newTerminalArgs{ nullptr };

            if (action.Action() == ShortcutAction::NewTab)
            {
                const auto& args{ action.Args().try_as<NewTabArgs>() };
                if (args)
                {
                    newTerminalArgs = args.TerminalArgs();
                }
                else
                {
                    // This was a nt action that didn't have any args. The default
                    // profile may want to be elevated, so don't just early return.
                }
            }