File tree Expand file tree Collapse file tree
crates/emmylua_code_analysis/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,6 +121,11 @@ fn pre_process_path(path: &str, workspace: &Path) -> String {
121121
122122 path = replace_placeholders ( & path, workspace_str) ;
123123
124+ fn canonicalize_path ( path_buf : PathBuf ) -> String {
125+ let new_path_buf = path_buf. canonicalize ( ) . unwrap_or ( path_buf) ;
126+ new_path_buf. to_string_lossy ( ) . to_string ( )
127+ }
128+
124129 if path. starts_with ( '~' ) {
125130 let home_dir = match dirs:: home_dir ( ) {
126131 Some ( path) => path,
@@ -129,13 +134,13 @@ fn pre_process_path(path: &str, workspace: &Path) -> String {
129134 return path;
130135 }
131136 } ;
132- path = home_dir. join ( & path[ 1 ..] ) . to_string_lossy ( ) . to_string ( ) ;
137+ path = canonicalize_path ( home_dir. join ( & path[ 1 ..] ) ) ;
133138 } else if path. starts_with ( "./" ) {
134- path = workspace. join ( & path[ 2 ..] ) . to_string_lossy ( ) . to_string ( ) ;
139+ path = canonicalize_path ( workspace. join ( & path[ 2 ..] ) ) ;
135140 } else if PathBuf :: from ( & path) . is_absolute ( ) {
136141 path = path. to_string ( ) ;
137142 } else {
138- path = workspace. join ( & path) . to_string_lossy ( ) . to_string ( ) ;
143+ path = canonicalize_path ( workspace. join ( & path) ) ;
139144 }
140145
141146 path
Original file line number Diff line number Diff line change @@ -61,7 +61,9 @@ pub fn load_workspace_files(
6161 . filter ( |e| e. file_type ( ) . is_file ( ) )
6262 {
6363 let path = entry. path ( ) ;
64- if exclude_dir. iter ( ) . any ( |dir| path. starts_with ( dir) ) {
64+ let raw_path_buf = path. to_path_buf ( ) ;
65+ let path_buf = raw_path_buf. canonicalize ( ) . unwrap_or ( raw_path_buf) ;
66+ if exclude_dir. iter ( ) . any ( |dir| path_buf. starts_with ( dir) ) {
6567 continue ;
6668 }
6769
You can’t perform that action at this time.
0 commit comments