Skip to content

fix: open Windows drive, UNC and MSYS paths from hints - #1951

Open
abcfy2 wants to merge 1 commit into
raphamorim:mainfrom
abcfy2:fix/hints-windows-paths-1943
Open

abcfy2 wants to merge 1 commit into
raphamorim:mainfrom
abcfy2:fix/hints-windows-paths-1943

Conversation

@abcfy2

@abcfy2 abcfy2 commented Sep 20, 2026

Copy link
Copy Markdown

Fixes #1943.

Problem

On Windows, clicking a hinted path that is not a scheme URL silently does nothing for the most common native and MSYS spellings:

  • drive-letter paths: C:\Users\me\notes.txt, C:/Users/me/notes.txt
  • UNC shares: \\server\share\doc.pdf, //server/share/doc.pdf
  • MSYS/Cygwin/WSL roots: /c/Users/me/notes.txt, /cygdrive/c/..., /mnt/c/...

Two gaps stack: the default hints regex has no branches for the Windows-only forms, and resolve_path_for_opening treats POSIX-rooted text as a relative path and joins it onto the OSC 7 cwd.

What this PR does

Detection (rio-backend/src/config/hints.rs): DEFAULT_URL_REGEX is now cfg-split. The Windows const keeps the shared alternations and adds three Windows-only branches — drive-letter paths (both separators), backslash UNC, and the MSYS forward-slash UNC spelling. All three require a dotted filename segment (mirroring the conservative bare-relative branch) and allow spaces and parentheses inside segments (Program Files (x86)). The non-Windows const is byte-for-byte unchanged.

Resolution (frontends/rioterm/src/hints.rs): resolve_path_for_opening gains a cfg(windows) step that converts POSIX-rooted text (/x/..., /cygdrive/x/..., /mnt/x/..., //host/share/...) to a Windows path and accepts it only if it exists, before the existing cwd-join fallback. OSC 8 file:// hyperlink clicks route through the same resolver, so MSYS-style OSC 8 links benefit too.

Deliberately not converted: multi-letter roots such as /tmp (the terminal cannot know which POSIX root they map to) and a bare single-letter /x (cd /d flag is ambiguous prose; ls /d/ with a trailing slash still converts).

Behavior matrix

Path form Needs shell cwd? Works in
C:\x\f.txt, C:/x/f.txt, \\srv\sh\d.pdf, //srv/sh/d.pdf no any shell
/c/..., /cygdrive/c/..., /mnt/c/... no any shell echoing them
relative (README.md, ./x) OSC 7 (unchanged) shells with shell integration

Testing

  • unit tests for the posix_to_windows decision table (single/multi-letter roots, explicit mount syntax, UNC, double separators, bare-flag rejection)
  • unit tests pinning the Windows regex branches (forms above, Program Files (x86), plus prose rejections: option C: drive, versions/timestamps)
  • non-Windows DEFAULT_URL_REGEX unchanged; existing suites pass (rio-backend 25/25 hints, rioterm 18/18 hints on Windows)

Windows terminals print several path forms the default hints regex
cannot match and the opener cannot resolve (rio issue raphamorim#1943):

- add Windows-only alternations to DEFAULT_URL_REGEX for drive-letter
  paths (C:\x\f.txt, C:/x/f.txt), backslash UNC (\\host\share\doc.pdf)
  and MSYS forward-slash UNC (//host/share/doc.pdf), all requiring a
  dotted filename segment and supporting spaces/parens in segments
- resolve_path_for_opening now converts POSIX-rooted MSYS/WSL text
  (/x/..., /cygdrive/x/..., /mnt/x/..., //host/share/...) to Windows
  paths with an existence check, before the cwd-join fallback
- multi-letter roots (/tmp) and bare single-letter prose (cd /d flag)
  are deliberately not converted

Fixes raphamorim#1943
@abcfy2
abcfy2 force-pushed the fix/hints-windows-paths-1943 branch from 7948d9d to 056ea49 Compare September 20, 2026 13:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Hints can't open drive-letter / UNC / MSYS-style paths — mintty's path-opening pipeline as a design reference

1 participant