File tree Expand file tree Collapse file tree
crates/emmylua_code_analysis/src/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,24 +73,18 @@ impl PreProcessContext {
7373
7474 path = self . replace_placeholders ( & path, workspace_str) ;
7575
76- if path. starts_with ( '~' ) {
76+ if let Some ( suffix ) = path. strip_prefix ( "~/" ) {
7777 let home_dir = match dirs:: home_dir ( ) {
78- Some ( path ) => path ,
78+ Some ( h ) => h ,
7979 None => {
8080 log:: error!( "Warning: Home directory not found" ) ;
8181 return path;
8282 }
8383 } ;
84- path = home_dir. join ( & path[ 2 ..] ) . to_string_lossy ( ) . to_string ( ) ;
85- } else if path. starts_with ( "./" ) {
86- path = self
87- . workspace
88- . join ( & path[ 2 ..] )
89- . to_string_lossy ( )
90- . to_string ( ) ;
91- } else if PathBuf :: from ( & path) . is_absolute ( ) {
92- path = path. to_string ( ) ;
93- } else {
84+ path = home_dir. join ( suffix) . to_string_lossy ( ) . to_string ( ) ;
85+ } else if let Some ( suffix) = path. strip_prefix ( "./" ) {
86+ path = self . workspace . join ( suffix) . to_string_lossy ( ) . to_string ( ) ;
87+ } else if !PathBuf :: from ( & path) . is_absolute ( ) {
9488 path = self . workspace . join ( & path) . to_string_lossy ( ) . to_string ( ) ;
9589 }
9690
You can’t perform that action at this time.
0 commit comments