fix<Preference>: fix external merge tool configuration lost when path can NOT be found automatically

This commit is contained in:
leo 2021-06-07 20:58:42 +08:00
parent dcf24db75a
commit e13467c457
2 changed files with 7 additions and 7 deletions

View file

@ -78,7 +78,6 @@ namespace SourceGit.Models {
/// 外部合并工具配置
/// </summary>
public class MergeToolInfo {
/// <summary>
/// 合并工具类型
/// </summary>
@ -87,7 +86,7 @@ namespace SourceGit.Models {
/// <summary>
/// 合并工具可执行文件路径
/// </summary>
public string Path { get; set; }
public string Path { get; set; } = "";
}
/// <summary>

View file

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