From 4fc32b2b59f414d508941a01777b6b74a733115e Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 27 Nov 2024 09:17:18 +0800 Subject: [PATCH] fix: crash due to font family name is an empty space (#745) --- src/ViewModels/Preference.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs index 70f0041f..1ccee4cd 100644 --- a/src/ViewModels/Preference.cs +++ b/src/ViewModels/Preference.cs @@ -65,7 +65,8 @@ namespace SourceGit.ViewModels get => _defaultFontFamily; set { - if (SetProperty(ref _defaultFontFamily, value) && !_isLoading) + var trimmed = value.Trim(); + if (SetProperty(ref _defaultFontFamily, trimmed) && !_isLoading) App.SetFonts(_defaultFontFamily, _monospaceFontFamily, _onlyUseMonoFontInEditor); } } @@ -75,7 +76,8 @@ namespace SourceGit.ViewModels get => _monospaceFontFamily; set { - if (SetProperty(ref _monospaceFontFamily, value) && !_isLoading) + var trimmed = value.Trim(); + if (SetProperty(ref _monospaceFontFamily, trimmed) && !_isLoading) App.SetFonts(_defaultFontFamily, _monospaceFontFamily, _onlyUseMonoFontInEditor); } }