@@ -293,14 +293,28 @@ private async void SelectShellOrTerminal(object _, RoutedEventArgs e)
293
293
return ;
294
294
295
295
var shell = Models . ShellOrTerminal . Supported [ type ] ;
296
- var options = new FilePickerOpenOptions ( )
296
+
297
+ var options = new FilePickerOpenOptions ( ) { AllowMultiple = false } ;
298
+ if ( shell . Name != "Custom" )
297
299
{
298
- FileTypeFilter = [ new FilePickerFileType ( shell . Name ) { Patterns = [ shell . Exec ] } ] ,
299
- AllowMultiple = false ,
300
- } ;
300
+ options = new FilePickerOpenOptions ( )
301
+ {
302
+ FileTypeFilter = [ new FilePickerFileType ( shell . Name ) { Patterns = [ shell . Exec ] } ] ,
303
+ AllowMultiple = false ,
304
+ } ;
305
+ }
301
306
302
- var selected = await StorageProvider . OpenFilePickerAsync ( options ) ;
303
- if ( selected . Count == 1 )
307
+ IReadOnlyList < IStorageFile > selected = null ;
308
+ try
309
+ {
310
+ selected = await StorageProvider . OpenFilePickerAsync ( options ) ;
311
+ }
312
+ catch ( Exception ex )
313
+ {
314
+ App . RaiseException ( string . Empty , $ "Failed to select shell/terminal: { ex . Message } ") ;
315
+ }
316
+
317
+ if ( selected is { Count : 1 } )
304
318
{
305
319
ViewModels . Preferences . Instance . ShellOrTerminalPath = selected [ 0 ] . Path . LocalPath ;
306
320
}
@@ -319,14 +333,27 @@ private async void SelectExternalMergeTool(object _, RoutedEventArgs e)
319
333
}
320
334
321
335
var tool = Models . ExternalMerger . Supported [ type ] ;
322
- var options = new FilePickerOpenOptions ( )
336
+ var options = new FilePickerOpenOptions ( ) { AllowMultiple = false } ;
337
+ if ( tool . Name != "Custom" )
323
338
{
324
- FileTypeFilter = [ new FilePickerFileType ( tool . Name ) { Patterns = tool . GetPatterns ( ) } ] ,
325
- AllowMultiple = false ,
326
- } ;
339
+ options = new FilePickerOpenOptions ( )
340
+ {
341
+ FileTypeFilter = [ new FilePickerFileType ( tool . Name ) { Patterns = tool . GetPatterns ( ) } ] ,
342
+ AllowMultiple = false ,
343
+ } ;
344
+ }
327
345
328
- var selected = await StorageProvider . OpenFilePickerAsync ( options ) ;
329
- if ( selected . Count == 1 )
346
+ IReadOnlyList < IStorageFile > selected = null ;
347
+ try
348
+ {
349
+ selected = await StorageProvider . OpenFilePickerAsync ( options ) ;
350
+ }
351
+ catch ( Exception ex )
352
+ {
353
+ App . RaiseException ( string . Empty , $ "Failed to select merge tool: { ex . Message } ") ;
354
+ }
355
+
356
+ if ( selected is { Count : 1 } )
330
357
{
331
358
ViewModels . Preferences . Instance . ExternalMergeToolPath = selected [ 0 ] . Path . LocalPath ;
332
359
}
0 commit comments