Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 39 additions & 12 deletions src/Views/Preferences.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,28 @@ private async void SelectShellOrTerminal(object _, RoutedEventArgs e)
return;

var shell = Models.ShellOrTerminal.Supported[type];
var options = new FilePickerOpenOptions()

var options = new FilePickerOpenOptions() { AllowMultiple = false };
if (shell.Name != "Custom")
{
FileTypeFilter = [new FilePickerFileType(shell.Name) { Patterns = [shell.Exec] }],
AllowMultiple = false,
};
options = new FilePickerOpenOptions()
{
FileTypeFilter = [new FilePickerFileType(shell.Name) { Patterns = [shell.Exec] }],
AllowMultiple = false,
};
}

var selected = await StorageProvider.OpenFilePickerAsync(options);
if (selected.Count == 1)
IReadOnlyList<IStorageFile> selected = null;
try
{
selected = await StorageProvider.OpenFilePickerAsync(options);
}
catch (Exception ex)
{
App.RaiseException(string.Empty, $"Failed to select shell/terminal: {ex.Message}");
}

if (selected is { Count: 1 })
{
ViewModels.Preferences.Instance.ShellOrTerminalPath = selected[0].Path.LocalPath;
}
Expand All @@ -319,14 +333,27 @@ private async void SelectExternalMergeTool(object _, RoutedEventArgs e)
}

var tool = Models.ExternalMerger.Supported[type];
var options = new FilePickerOpenOptions()
var options = new FilePickerOpenOptions() { AllowMultiple = false };
if (tool.Name != "Custom")
{
FileTypeFilter = [new FilePickerFileType(tool.Name) { Patterns = tool.GetPatterns() }],
AllowMultiple = false,
};
options = new FilePickerOpenOptions()
{
FileTypeFilter = [new FilePickerFileType(tool.Name) { Patterns = tool.GetPatterns() }],
AllowMultiple = false,
};
}

var selected = await StorageProvider.OpenFilePickerAsync(options);
if (selected.Count == 1)
IReadOnlyList<IStorageFile> selected = null;
try
{
selected = await StorageProvider.OpenFilePickerAsync(options);
}
catch (Exception ex)
{
App.RaiseException(string.Empty, $"Failed to select merge tool: {ex.Message}");
}

if (selected is { Count: 1 })
{
ViewModels.Preferences.Instance.ExternalMergeToolPath = selected[0].Path.LocalPath;
}
Expand Down