1313using Windows . Win32 ;
1414using Windows . Win32 . Foundation ;
1515using Windows . Win32 . UI . Accessibility ;
16+ using System . Collections . Concurrent ;
1617
1718namespace Flow . Launcher . Infrastructure . DialogJump
1819{
@@ -60,12 +61,12 @@ public static class DialogJump
6061
6162 private static HWND _mainWindowHandle = HWND . Null ;
6263
63- private static readonly Dictionary < DialogJumpExplorerPair , IDialogJumpExplorerWindow > _dialogJumpExplorers = new ( ) ;
64+ private static readonly ConcurrentDictionary < DialogJumpExplorerPair , IDialogJumpExplorerWindow > _dialogJumpExplorers = new ( ) ;
6465
6566 private static DialogJumpExplorerPair _lastExplorer = null ;
6667 private static readonly Lock _lastExplorerLock = new ( ) ;
6768
68- private static readonly Dictionary < DialogJumpDialogPair , IDialogJumpDialogWindow > _dialogJumpDialogs = new ( ) ;
69+ private static readonly ConcurrentDictionary < DialogJumpDialogPair , IDialogJumpDialogWindow > _dialogJumpDialogs = new ( ) ;
6970
7071 private static IDialogJumpDialogWindow _dialogWindow = null ;
7172 private static readonly Lock _dialogWindowLock = new ( ) ;
@@ -101,22 +102,13 @@ public static class DialogJump
101102
102103 #region Initialize & Setup
103104
104- public static void InitializeDialogJump ( IList < DialogJumpExplorerPair > dialogJumpExplorers ,
105- IList < DialogJumpDialogPair > dialogJumpDialogs )
105+ public static void InitializeDialogJump ( )
106106 {
107107 if ( _initialized ) return ;
108108
109- // Initialize Dialog Jump explorers & dialogs
110- _dialogJumpExplorers . Add ( WindowsDialogJumpExplorer , null ) ;
111- foreach ( var explorer in dialogJumpExplorers )
112- {
113- _dialogJumpExplorers . Add ( explorer , null ) ;
114- }
115- _dialogJumpDialogs . Add ( WindowsDialogJumpDialog , null ) ;
116- foreach ( var dialog in dialogJumpDialogs )
117- {
118- _dialogJumpDialogs . Add ( dialog , null ) ;
119- }
109+ // Initialize preinstalled Dialog Jump explorers & dialogs
110+ _dialogJumpExplorers . TryAdd ( WindowsDialogJumpExplorer , null ) ;
111+ _dialogJumpDialogs . TryAdd ( WindowsDialogJumpDialog , null ) ;
120112
121113 // Initialize main window handle
122114 _mainWindowHandle = Win32Helper . GetMainWindowHandle ( ) ;
@@ -131,6 +123,29 @@ public static void InitializeDialogJump(IList<DialogJumpExplorerPair> dialogJump
131123 _initialized = true ;
132124 }
133125
126+ public static void InitializeDialogJumpPlugin ( PluginPair pair )
127+ {
128+ // Add Dialog Jump explorers & dialogs
129+ if ( pair . Plugin is IDialogJumpExplorer explorer )
130+ {
131+ var dialogJumpExplorer = new DialogJumpExplorerPair
132+ {
133+ Plugin = explorer ,
134+ Metadata = pair . Metadata
135+ } ;
136+ _dialogJumpExplorers . TryAdd ( dialogJumpExplorer , null ) ;
137+ }
138+ if ( pair . Plugin is IDialogJumpDialog dialog )
139+ {
140+ var dialogJumpDialog = new DialogJumpDialogPair
141+ {
142+ Plugin = dialog ,
143+ Metadata = pair . Metadata
144+ } ;
145+ _dialogJumpDialogs . TryAdd ( dialogJumpDialog , null ) ;
146+ }
147+ }
148+
134149 public static void SetupDialogJump ( bool enabled )
135150 {
136151 if ( enabled == _enabled ) return ;
@@ -828,9 +843,25 @@ private static bool CheckPath(string path, out bool file)
828843 return true ;
829844 }
830845 // file: URI paths
831- var localPath = path . StartsWith ( "file:" , StringComparison . OrdinalIgnoreCase )
832- ? new Uri ( path ) . LocalPath
833- : path ;
846+ string localPath ;
847+ if ( path . StartsWith ( "file:" , StringComparison . OrdinalIgnoreCase ) )
848+ {
849+ // Try to create a URI from the path
850+ if ( Uri . TryCreate ( path , UriKind . Absolute , out var uri ) )
851+ {
852+ localPath = uri . LocalPath ;
853+ }
854+ else
855+ {
856+ // If URI creation fails, treat it as a regular path
857+ // by removing the "file:" prefix
858+ localPath = path . Substring ( 5 ) ;
859+ }
860+ }
861+ else
862+ {
863+ localPath = path ;
864+ }
834865 // Is folder?
835866 var isFolder = Directory . Exists ( localPath ) ;
836867 // Is file?
0 commit comments