Skip to content

Commit 80f7bdf

Browse files
authored
Merge pull request #7 from dsully/fix-library-absolute-path
Allow absolute paths to be used by removing unneeded branch that checks for '/'
2 parents 093a17d + 7ef348a commit 80f7bdf

File tree

1 file changed

+4
-9
lines changed
  • crates/code_analysis/src/config

1 file changed

+4
-9
lines changed

crates/code_analysis/src/config/mod.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod config_loader;
22
mod configs;
33
mod flatten_config;
44

5-
use std::{collections::HashSet, path::PathBuf};
5+
use std::{collections::HashSet, path::{Path, PathBuf}};
66

77
use crate::{semantic::LuaInferConfig, FileId};
88
pub use config_loader::load_configs;
@@ -80,10 +80,10 @@ impl Emmyrc {
8080
ParserConfig::new(lua_language_level, Some(node_cache))
8181
}
8282

83-
pub fn pre_process_emmyrc(&mut self, workspace_root: &PathBuf) {
83+
pub fn pre_process_emmyrc(&mut self, workspace_root: &Path) {
8484
fn process_and_dedup<'a>(
8585
iter: impl Iterator<Item = &'a String>,
86-
workspace_root: &PathBuf,
86+
workspace_root: &Path,
8787
) -> Vec<String> {
8888
let mut seen = HashSet::new();
8989
iter.map(|root| pre_process_path(root, workspace_root))
@@ -102,19 +102,14 @@ impl Emmyrc {
102102
}
103103
}
104104

105-
fn pre_process_path(path: &str, workspace: &PathBuf) -> String {
105+
fn pre_process_path(path: &str, workspace: &Path) -> String {
106106
let mut path = path.to_string();
107107

108108
if path.starts_with('~') {
109109
let home_dir = dirs::home_dir().unwrap();
110110
path = home_dir.join(&path[1..]).to_string_lossy().to_string();
111111
} else if path.starts_with("./") {
112112
path = workspace.join(&path[2..]).to_string_lossy().to_string();
113-
} else if path.starts_with('/') {
114-
path = workspace
115-
.join(path.trim_start_matches('/'))
116-
.to_string_lossy()
117-
.to_string();
118113
} else if PathBuf::from(&path).is_absolute() {
119114
path = path.to_string();
120115
} else {

0 commit comments

Comments
 (0)