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

Code before:
        // profile, which might have changed
        _UpdateTabWidthMode();
        _CreateNewTabFlyout();

        // Reload the current value of alwaysOnTop from the settings file. This
        // will let the user hot-reload this setting, but any runtime changes to
        // the alwaysOnTop setting will be lost.
        _isAlwaysOnTop = _settings.GlobalSettings().AlwaysOnTop();
        _AlwaysOnTopChangedHandlers(*this, nullptr);

        // Settings AllowDependentAnimations will affect whether animations are
        // enabled application-wide, so we don't need to check it each time we
        // want to create an animation.
        WUX::Media::Animation::Timeline::AllowDependentAnimations(!_settings.GlobalSettings().DisableAnimations());

        _tabRow.ShowElevationShield(IsRunningElevated() && _settings.GlobalSettings().ShowAdminShield());

        Media::SolidColorBrush transparent{ Windows::UI::Colors::Transparent() };
        _tabView.Background(transparent);

        ////////////////////////////////////////////////////////////////////////
        // Begin Theme handling
        _updateThemeColors();

        const auto tab{ _GetFocusedTab() };
        _updateTabsCloseButton(tab);
    }

    void TerminalPage::_updateTabsCloseButton(const winrt::TerminalApp::TabBase& focusedTab)
    {
        // Update the state of the CloseButtonOverlayMode property of
        // our TabView, to match the tab.showCloseButton property in the theme.
        //
        // Also update every tab's individual IsClosable to match.
        const auto theme = _settings.GlobalSettings().CurrentTheme();
        const auto visibility = theme && theme.Tab() ? theme.Tab().ShowCloseButton() : Settings::Model::TabCloseButtonVisibility::Always;

        for (const auto& tab : _tabs)
        {
            switch (visibility)
            {
            case Settings::Model::TabCloseButtonVisibility::Never:
                tab.TabViewItem().IsClosable(false);
                break;
            case Settings::Model::TabCloseButtonVisibility::Hover:
                tab.TabViewItem().IsClosable(true);
                break;
            case Settings::Model::TabCloseButtonVisibility::ActiveOnly:
            {
                if (focusedTab && focusedTab == tab)
                {

Review comment (suggestion):
nit: no extra var necessary
```suggestion
        _updateTabsCloseButton(_GetFocusedTab());
```

Code after:
        // profile, which might have changed
        _UpdateTabWidthMode();
        _CreateNewTabFlyout();

        // Reload the current value of alwaysOnTop from the settings file. This
        // will let the user hot-reload this setting, but any runtime changes to
        // the alwaysOnTop setting will be lost.
        _isAlwaysOnTop = _settings.GlobalSettings().AlwaysOnTop();
        _AlwaysOnTopChangedHandlers(*this, nullptr);

        // Settings AllowDependentAnimations will affect whether animations are
        // enabled application-wide, so we don't need to check it each time we
        // want to create an animation.
        WUX::Media::Animation::Timeline::AllowDependentAnimations(!_settings.GlobalSettings().DisableAnimations());

        _tabRow.ShowElevationShield(IsRunningElevated() && _settings.GlobalSettings().ShowAdminShield());

        Media::SolidColorBrush transparent{ Windows::UI::Colors::Transparent() };
        _tabView.Background(transparent);

        ////////////////////////////////////////////////////////////////////////
        // Begin Theme handling
        _updateThemeColors();

        _updateAllTabCloseButtons(_GetFocusedTab());
    }

    void TerminalPage::_updateAllTabCloseButtons(const winrt::TerminalApp::TabBase& focusedTab)
    {
        // Update the state of the CloseButtonOverlayMode property of
        // our TabView, to match the tab.showCloseButton property in the theme.
        //
        // Also update every tab's individual IsClosable to match the same property.
        const auto theme = _settings.GlobalSettings().CurrentTheme();
        const auto visibility = theme && theme.Tab() ? theme.Tab().ShowCloseButton() : Settings::Model::TabCloseButtonVisibility::Always;

        for (const auto& tab : _tabs)
        {
            switch (visibility)
            {
            case Settings::Model::TabCloseButtonVisibility::Never:
                tab.TabViewItem().IsClosable(false);
                break;
            case Settings::Model::TabCloseButtonVisibility::Hover:
                tab.TabViewItem().IsClosable(true);
                break;
            case Settings::Model::TabCloseButtonVisibility::ActiveOnly:
            {
                if (focusedTab && focusedTab == tab)
                {
                    tab.TabViewItem().IsClosable(true);