Make project detection independent of OS

This commit is contained in:
Patrick Förster 2023-04-29 13:31:02 +02:00
parent 6188ddf4fb
commit 2b11488d4a
3 changed files with 13 additions and 6 deletions

View file

@ -14,6 +14,7 @@ log = "0.4.17"
notify = "5.1.0"
once_cell = "1.17.1"
parser = { path = "../parser" }
percent-encoding = "2.2.0"
regex = "1.7.3"
rowan = "0.15.11"
rustc-hash = "1.1.0"

View file

@ -3,6 +3,7 @@ use std::{ffi::OsStr, path::PathBuf};
use distro::Language;
use itertools::Itertools;
use once_cell::sync::Lazy;
use percent_encoding::percent_decode_str;
use rustc_hash::FxHashSet;
use url::Url;
@ -138,12 +139,16 @@ impl<'a> Graph<'a> {
}
fn implicit_edge(&mut self, source: &'a Document, base_dir: &Url, extension: &str) {
let Some(target_uri) = source.uri.to_file_path().ok().and_then(|mut path| {
path.set_extension(extension);
path.file_name()
.and_then(OsStr::to_str)
.and_then(|name| self.workspace.output_dir(base_dir).join(&name).ok())
}) else { return };
let mut path = PathBuf::from(
percent_decode_str(source.uri.path())
.decode_utf8_lossy()
.as_ref(),
);
path.set_extension(extension);
let Some(target_uri) = path.file_name()
.and_then(OsStr::to_str)
.and_then(|name| self.workspace.output_dir(base_dir).join(&name).ok()) else { return };
match self.workspace.lookup(&target_uri) {
Some(target) => {