File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,8 @@ use std::{env, io};
6262///
6363/// - On Windows the `ShellExecuteW` Windows API function is used.
6464/// - On Mac the system `open` command is used.
65- /// - On Windows Subsystem for Linux (WSL), the system `xdg-open` will be used if available,
66- /// otherwise the system `wslview` from [`wslu`] is used.
65+ /// - On Windows Subsystem for Linux (WSL), the system `wslview` from [`wslu`] is used if available,
66+ /// otherwise the system `xdg-open` is used, if available .
6767/// - On non-WSL Linux and other platforms,
6868/// the system `xdg-open` script is used if available, otherwise an `xdg-open` script embedded in
6969/// this library is used.
Original file line number Diff line number Diff line change @@ -14,26 +14,32 @@ pub(crate) fn open(path: &OsStr) -> Result<(), OpenError> {
1414}
1515
1616fn wsl_open ( path : & OsStr ) -> Result < ( ) , OpenError > {
17- let system_xdg_open = Command :: new ( "xdg-open" )
17+ let transformed_path = crate :: wsl_to_windows_path ( path) ;
18+ let transformed_path = transformed_path. as_deref ( ) ;
19+ let path = match transformed_path {
20+ None => path,
21+ Some ( x) => x,
22+ } ;
23+ let wslview = Command :: new ( "wslview" )
1824 . arg ( path)
1925 . stdin ( Stdio :: null ( ) )
2026 . stdout ( Stdio :: null ( ) )
2127 . stderr ( Stdio :: piped ( ) )
2228 . spawn ( ) ;
2329
24- if let Ok ( mut child) = system_xdg_open {
25- return crate :: wait_child ( & mut child, "xdg-open (system) " . into ( ) ) ;
30+ if let Ok ( mut child) = wslview {
31+ return crate :: wait_child ( & mut child, "wslview " . into ( ) ) ;
2632 }
2733
28- let mut wslview = Command :: new ( "wslview " )
34+ let mut system_xdg_open = Command :: new ( "xdg-open " )
2935 . arg ( path)
3036 . stdin ( Stdio :: null ( ) )
3137 . stdout ( Stdio :: null ( ) )
3238 . stderr ( Stdio :: piped ( ) )
3339 . spawn ( )
3440 . map_err ( OpenError :: Io ) ?;
3541
36- crate :: wait_child ( & mut wslview , "wslview " . into ( ) )
42+ crate :: wait_child ( & mut system_xdg_open , "xdg-open (system) " . into ( ) )
3743}
3844
3945fn non_wsl_open ( path : & OsStr ) -> Result < ( ) , OpenError > {
You can’t perform that action at this time.
0 commit comments