1- #[ cfg( windows ) ]
1+ #[ cfg( feature = "wsl" ) ]
22use std:: string:: FromUtf16Error ;
33use std:: {
44 borrow:: Cow ,
55 mem:: take,
66 path:: { PathBuf , MAIN_SEPARATOR } ,
77} ;
88
9- #[ cfg( windows ) ]
9+ #[ cfg( feature = "wsl" ) ]
1010use anyhow:: { Context , Result } ;
1111use const_format:: formatcp;
1212use egui:: {
@@ -43,7 +43,7 @@ pub struct ConfigViewState {
4343 pub object_search : String ,
4444 pub filter_diffable : bool ,
4545 pub filter_incomplete : bool ,
46- #[ cfg( windows ) ]
46+ #[ cfg( feature = "wsl" ) ]
4747 pub available_wsl_distros : Option < Vec < String > > ,
4848}
4949
@@ -87,7 +87,7 @@ pub const DEFAULT_WATCH_PATTERNS: &[&str] = &[
8787 "*.inc" , "*.py" , "*.yml" , "*.txt" , "*.json" ,
8888] ;
8989
90- #[ cfg( windows ) ]
90+ #[ cfg( feature = "wsl" ) ]
9191fn process_utf16 ( bytes : & [ u8 ] ) -> Result < String , FromUtf16Error > {
9292 let u16_bytes: Vec < u16 > = bytes
9393 . chunks_exact ( 2 )
@@ -96,7 +96,7 @@ fn process_utf16(bytes: &[u8]) -> Result<String, FromUtf16Error> {
9696 String :: from_utf16 ( & u16_bytes)
9797}
9898
99- #[ cfg( windows ) ]
99+ #[ cfg( feature = "wsl" ) ]
100100fn wsl_cmd ( args : & [ & str ] ) -> Result < String > {
101101 use std:: { os:: windows:: process:: CommandExt , process:: Command } ;
102102 let output = Command :: new ( "wsl" )
@@ -107,7 +107,7 @@ fn wsl_cmd(args: &[&str]) -> Result<String> {
107107 process_utf16 ( & output. stdout ) . context ( "Failed to process stdout" )
108108}
109109
110- #[ cfg( windows ) ]
110+ #[ cfg( feature = "wsl" ) ]
111111fn fetch_wsl2_distros ( ) -> Vec < String > {
112112 wsl_cmd ( & [ "-l" , "-q" ] )
113113 . map ( |stdout| {
@@ -180,7 +180,7 @@ pub fn config_ui(
180180 }
181181 ui. separator ( ) ;
182182
183- #[ cfg( windows ) ]
183+ #[ cfg( feature = "wsl" ) ]
184184 {
185185 ui. heading ( "Build" ) ;
186186 if state. available_wsl_distros . is_none ( ) {
@@ -196,7 +196,7 @@ pub fn config_ui(
196196 } ) ;
197197 ui. separator ( ) ;
198198 }
199- #[ cfg( not( windows ) ) ]
199+ #[ cfg( not( feature = "wsl" ) ) ]
200200 {
201201 let _ = selected_wsl_distro;
202202 }
0 commit comments