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; }