From e13467c457675d653cb1eb9d0d312b90b4c6c254 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 7 Jun 2021 20:58:42 +0800 Subject: [PATCH] fix: fix external merge tool configuration lost when path can NOT be found automatically --- src/Models/Preference.cs | 3 +-- src/Views/Preference.xaml.cs | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Models/Preference.cs b/src/Models/Preference.cs index 9b3e4bff..635ffb9e 100644 --- a/src/Models/Preference.cs +++ b/src/Models/Preference.cs @@ -78,7 +78,6 @@ namespace SourceGit.Models { /// 外部合并工具配置 /// public class MergeToolInfo { - /// /// 合并工具类型 /// @@ -87,7 +86,7 @@ namespace SourceGit.Models { /// /// 合并工具可执行文件路径 /// - public string Path { get; set; } + public string Path { get; set; } = ""; } /// diff --git a/src/Views/Preference.xaml.cs b/src/Views/Preference.xaml.cs index 8587f2fb..dd28ff71 100644 --- a/src/Views/Preference.xaml.cs +++ b/src/Views/Preference.xaml.cs @@ -87,17 +87,18 @@ namespace SourceGit.Views { } private void MergeToolChanged(object sender, SelectionChangedEventArgs e) { - var selector = sender as ComboBox; - var type = (int)selector.SelectedValue; + var type = (int)(sender as ComboBox).SelectedValue; var tool = Models.MergeTool.Supported.Find(x => x.Type == type); if (tool == null) return; - Models.Preference.Instance.MergeTool.Path = tool.Finder(); MergeCmd = tool.Cmd; - - txtMergeExec?.GetBindingExpression(TextBox.TextProperty).UpdateTarget(); txtMergeCmd?.GetBindingExpression(TextBlock.TextProperty).UpdateTarget(); + if (IsLoaded) { + Models.Preference.Instance.MergeTool.Path = tool.Finder(); + txtMergeExec?.GetBindingExpression(TextBox.TextProperty).UpdateTarget(); + } + e.Handled = true; }