Skip to content

Commit 2b05e4f

Browse files
committed
Code quality
1 parent a7916ac commit 2b05e4f

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

Flow.Launcher.Infrastructure/QuickSwitch/QuickSwitch.cs

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -520,62 +520,7 @@ uint dwmsEventTime
520520

521521
#region Navigate Path
522522

523-
private static void NavigateDialogPath(HWND dialog, Action action = null)
524-
{
525-
if (dialog == HWND.Null || GetWindowClassName(dialog) != DialogWindowClassName) return;
526-
527-
object document = null;
528-
try
529-
{
530-
lock (_lastExplorerViewLock)
531-
{
532-
if (_lastExplorerView != null)
533-
{
534-
// Use dynamic here because using IWebBrower2.Document can cause exception here:
535-
// System.Runtime.InteropServices.InvalidOleVariantTypeException: 'Specified OLE variant is invalid.'
536-
dynamic explorerView = _lastExplorerView;
537-
document = explorerView.Document;
538-
}
539-
}
540-
}
541-
catch (COMException)
542-
{
543-
return;
544-
}
545-
546-
if (document is not IShellFolderViewDual2 folderView)
547-
{
548-
return;
549-
}
550-
551-
string path;
552-
try
553-
{
554-
// CSWin32 Folder does not have Self, so we need to use dynamic type here
555-
// Use dynamic to bypass static typing
556-
dynamic folder = folderView.Folder;
557-
558-
// Access the Self property via dynamic binding
559-
dynamic folderItem = folder.Self;
560-
561-
// Check if the item is part of the file system
562-
if (folderItem != null && folderItem.IsFileSystem)
563-
{
564-
path = folderItem.Path;
565-
}
566-
else
567-
{
568-
// Handle non-file system paths (e.g., virtual folders)
569-
path = string.Empty;
570-
}
571-
}
572-
catch
573-
{
574-
return;
575-
}
576-
577-
JumpToPath(dialog.Value, path, action);
578-
}
523+
// Edited from: https://github.com/idkidknow/Flow.Launcher.Plugin.DirQuickJump
579524

580525
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD101:Avoid unsupported async delegates", Justification = "<Pending>")]
581526
public static void JumpToPath(nint dialog, string path, Action action = null)
@@ -673,9 +618,64 @@ static bool CheckPath(string path, out bool file)
673618
}
674619
}
675620

676-
// Edited from: https://github.com/idkidknow/Flow.Launcher.Plugin.DirQuickJump
621+
private static void NavigateDialogPath(HWND dialog, Action action = null)
622+
{
623+
if (dialog == HWND.Null || GetWindowClassName(dialog) != DialogWindowClassName) return;
624+
625+
object document = null;
626+
try
627+
{
628+
lock (_lastExplorerViewLock)
629+
{
630+
if (_lastExplorerView != null)
631+
{
632+
// Use dynamic here because using IWebBrower2.Document can cause exception here:
633+
// System.Runtime.InteropServices.InvalidOleVariantTypeException: 'Specified OLE variant is invalid.'
634+
dynamic explorerView = _lastExplorerView;
635+
document = explorerView.Document;
636+
}
637+
}
638+
}
639+
catch (COMException)
640+
{
641+
return;
642+
}
643+
644+
if (document is not IShellFolderViewDual2 folderView)
645+
{
646+
return;
647+
}
648+
649+
string path;
650+
try
651+
{
652+
// CSWin32 Folder does not have Self, so we need to use dynamic type here
653+
// Use dynamic to bypass static typing
654+
dynamic folder = folderView.Folder;
655+
656+
// Access the Self property via dynamic binding
657+
dynamic folderItem = folder.Self;
658+
659+
// Check if the item is part of the file system
660+
if (folderItem != null && folderItem.IsFileSystem)
661+
{
662+
path = folderItem.Path;
663+
}
664+
else
665+
{
666+
// Handle non-file system paths (e.g., virtual folders)
667+
path = string.Empty;
668+
}
669+
}
670+
catch
671+
{
672+
return;
673+
}
674+
675+
JumpToPath(dialog.Value, path, action);
676+
}
677677

678-
internal static bool FileJump(string filePath, HWND dialogHandle, bool forceFileName = false, bool openFile = false)
678+
private static bool FileJump(string filePath, HWND dialogHandle, bool forceFileName = false, bool openFile = false)
679679
{
680680
if (forceFileName)
681681
{
@@ -687,7 +687,7 @@ internal static bool FileJump(string filePath, HWND dialogHandle, bool forceFile
687687
}
688688
}
689689

690-
internal static bool DirJump(string dirPath, HWND dialogHandle)
690+
private static bool DirJump(string dirPath, HWND dialogHandle)
691691
{
692692
return DirFileJump(dirPath, null, dialogHandle);
693693
}

0 commit comments

Comments
 (0)