mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
feature<ExternalMergeTool>: use default path if file exists after tool changed
This commit is contained in:
parent
1a27b1dfb1
commit
e7219b4278
2 changed files with 13 additions and 5 deletions
|
@ -123,7 +123,14 @@ namespace SourceGit.ViewModels {
|
|||
|
||||
public int ExternalMergeToolType {
|
||||
get => _externalMergeToolType;
|
||||
set => SetProperty(ref _externalMergeToolType, value);
|
||||
set {
|
||||
var changed = SetProperty(ref _externalMergeToolType, value);
|
||||
if (changed && !OperatingSystem.IsWindows() && value >= 0 && value < Models.ExternalMergeTools.Supported.Count) {
|
||||
var tool = Models.ExternalMergeTools.Supported[value];
|
||||
if (File.Exists(tool.Exec)) ExternalMergeToolPath = tool.Exec;
|
||||
else ExternalMergeToolPath = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ExternalMergeToolPath {
|
||||
|
|
|
@ -115,14 +115,15 @@ namespace SourceGit.Views {
|
|||
|
||||
private async void SelectExternalMergeTool(object sender, RoutedEventArgs e) {
|
||||
var type = ViewModels.Preference.Instance.ExternalMergeToolType;
|
||||
if (type == 0 || type >= Models.ExternalMergeTools.Supported.Count) {
|
||||
ViewModels.Preference.Instance.ExternalMergeToolType = 1;
|
||||
type = 1;
|
||||
if (type < 0 || type >= Models.ExternalMergeTools.Supported.Count) {
|
||||
ViewModels.Preference.Instance.ExternalMergeToolType = 0;
|
||||
type = 0;
|
||||
}
|
||||
|
||||
var tool = Models.ExternalMergeTools.Supported[type];
|
||||
var pattern = Path.GetFileName(tool.Exec);
|
||||
var options = new FilePickerOpenOptions() {
|
||||
FileTypeFilter = [new FilePickerFileType(tool.Name) { Patterns = [tool.Exec] }],
|
||||
FileTypeFilter = [new FilePickerFileType(tool.Name) { Patterns = [pattern] }],
|
||||
AllowMultiple = false,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue