diff --git a/src/gui/components/_legacy.py b/src/gui/components/_legacy.py index 1483137..1cdb2d1 100644 --- a/src/gui/components/_legacy.py +++ b/src/gui/components/_legacy.py @@ -258,14 +258,18 @@ def _open_in_file_manager(folder: "Path", *, select: "Path | None" = None) -> bo """Open the OS file manager at *folder*, optionally highlighting *select*. Windows - ``explorer /select,`` is preferred when *select* is given — - Explorer pops to the foreground with the freshly-saved file - already highlighted. Falls back to ``explorer ``, then - ``os.startfile`` if both fail; ``os.startfile`` is known to - silently no-op or open behind the active window in some Windows - configurations, which is why we don't lead with it. + ``explorer `` only. We deliberately do NOT use + ``explorer /select,``: when the path contains a space + (e.g. ``C:\\Users\\Michael Dombaugh\\Downloads``), Python's + ``subprocess.Popen`` quotes the ``/select,...`` argument as one + unit, and Explorer's ``/select`` parser does not handle that + form — it silently falls back to opening the user's default + view (typically Documents). Opening the bare folder works + reliably regardless of spaces. ``os.startfile`` is kept as a + last-resort fallback only. macOS - ``open -R `` reveals the file in Finder. + ``open -R `` reveals the file in Finder when ``select`` + is given; otherwise just opens the folder. Linux / *BSD ``xdg-open`` on the folder. No reliable cross-distro way to highlight a specific file. @@ -278,19 +282,11 @@ def _open_in_file_manager(folder: "Path", *, select: "Path | None" = None) -> bo import subprocess if sys.platform == "win32": - # explorer.exe with /select wants a literal "/select," followed - # by the path — no space between the comma and the filename, or - # Explorer misinterprets and opens "My Computer" instead. - attempts = [] - if select is not None: - attempts.append(["explorer", f"/select,{select}"]) - attempts.append(["explorer", str(folder)]) - for cmd in attempts: - try: - subprocess.Popen(cmd) - return True - except Exception: - continue + try: + subprocess.Popen(["explorer", str(folder)]) + return True + except Exception: + pass try: os.startfile(str(folder)) # type: ignore[attr-defined] return True