Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsEditor/Profiles_Appearance.cpp (C++)

Code before:
        _AppearanceViewModelChangedRevoker = _Profile.DefaultAppearance().PropertyChanged(winrt::auto_revoke, { this, &Profiles_Appearance::_onProfilePropertyChanged });
    }

    void Profiles_Appearance::OnNavigatedFrom(const NavigationEventArgs& /*e*/)
    {
        _ViewModelChangedRevoker.revoke();
        _AppearanceViewModelChangedRevoker.revoke();
    }

    void Profiles_Appearance::CreateUnfocusedAppearance_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
    {
        _Profile.CreateUnfocusedAppearance();
    }

    void Profiles_Appearance::DeleteUnfocusedAppearance_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
    {
        _Profile.DeleteUnfocusedAppearance();
    }

    bool Profiles_Appearance::_looksLikePowerlineFont() const
    {
        if (_Profile && _Profile.DefaultAppearance())
        {
            if (auto fontName = _Profile.DefaultAppearance().FontFace(); !fontName.empty())
            {
                if (auto font = ProfileViewModel::FindFontWithLocalizedName(fontName))
                {
                    return font.HasPowerlineCharacters();
                }
            }
        }
        return false;
    }

    void Profiles_Appearance::_onProfilePropertyChanged(const IInspectable&, const PropertyChangedEventArgs&) const
    {
        const auto settings = _Profile.TermSettings();
        _previewConnection->DisplayPowerlineGlyphs(_looksLikePowerlineFont());
        _previewControl.UpdateControlSettings(settings, settings);
    }
}


Review comment (suggestion):
```suggestion
            if (const auto fontName = _Profile.DefaultAppearance().FontFace(); !fontName.empty())
            {
                if (const auto font = ProfileViewModel::FindFontWithLocalizedName(fontName))
```

Code after:
        _AppearanceViewModelChangedRevoker = _Profile.DefaultAppearance().PropertyChanged(winrt::auto_revoke, { this, &Profiles_Appearance::_onProfilePropertyChanged });
    }

    void Profiles_Appearance::OnNavigatedFrom(const NavigationEventArgs& /*e*/)
    {
        _ViewModelChangedRevoker.revoke();
        _AppearanceViewModelChangedRevoker.revoke();
    }

    void Profiles_Appearance::CreateUnfocusedAppearance_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
    {
        _Profile.CreateUnfocusedAppearance();
    }

    void Profiles_Appearance::DeleteUnfocusedAppearance_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/)
    {
        _Profile.DeleteUnfocusedAppearance();
    }

    bool Profiles_Appearance::_looksLikePowerlineFont() const
    {
        if (_Profile && _Profile.DefaultAppearance())
        {
            if (const auto fontName = _Profile.DefaultAppearance().FontFace(); !fontName.empty())
            {
                if (const auto font = ProfileViewModel::FindFontWithLocalizedName(fontName))
                {
                    return font.HasPowerlineCharacters();
                }
            }
        }
        return false;
    }

    void Profiles_Appearance::_onProfilePropertyChanged(const IInspectable&, const PropertyChangedEventArgs&) const
    {
        const auto settings = _Profile.TermSettings();
        _previewConnection->DisplayPowerlineGlyphs(_looksLikePowerlineFont());
        _previewControl.UpdateControlSettings(settings, settings);
    }
}