Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions crates/emmylua_code_analysis/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ fn pre_process_path(path: &str, workspace: &Path) -> String {

path = replace_placeholders(&path, workspace_str);

fn canonicalize_path(path_buf: PathBuf) -> String {
let new_path_buf = path_buf.canonicalize().unwrap_or(path_buf);
new_path_buf.to_string_lossy().to_string()
}

if path.starts_with('~') {
let home_dir = match dirs::home_dir() {
Some(path) => path,
Expand All @@ -129,13 +134,13 @@ fn pre_process_path(path: &str, workspace: &Path) -> String {
return path;
}
};
path = home_dir.join(&path[1..]).to_string_lossy().to_string();
path = canonicalize_path(home_dir.join(&path[1..]));
} else if path.starts_with("./") {
path = workspace.join(&path[2..]).to_string_lossy().to_string();
path = canonicalize_path(workspace.join(&path[2..]));
} else if PathBuf::from(&path).is_absolute() {
path = path.to_string();
} else {
path = workspace.join(&path).to_string_lossy().to_string();
path = canonicalize_path(workspace.join(&path));
}

path
Expand Down
4 changes: 3 additions & 1 deletion crates/emmylua_code_analysis/src/vfs/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ pub fn load_workspace_files(
.filter(|e| e.file_type().is_file())
{
let path = entry.path();
if exclude_dir.iter().any(|dir| path.starts_with(dir)) {
let raw_path_buf = path.to_path_buf();
let path_buf = raw_path_buf.canonicalize().unwrap_or(raw_path_buf);
if exclude_dir.iter().any(|dir| path_buf.starts_with(dir)) {
continue;
}

Expand Down