Skip to content

Commit f171d2b

Browse files
committed
fix: strict tilde match
1 parent 97ea052 commit f171d2b

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

crates/emmylua_code_analysis/src/config/pre_process.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)