Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit c4650b6

Browse files
author
Hendrik van Antwerpen
committed
Do not compute package-relative paths only for tsconfig
1 parent 85e67b5 commit c4650b6

File tree

1 file changed

+30
-24
lines changed
  • languages/tree-sitter-stack-graphs-typescript/rust

1 file changed

+30
-24
lines changed

languages/tree-sitter-stack-graphs-typescript/rust/tsconfig.rs

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -399,42 +399,48 @@ impl TsConfig {
399399
}
400400

401401
/// Returns an iterator over the input files of the project, taking `files`, `include`, and `exclude` into account.
402-
fn input_files<'a, PI>(&self, source_paths: PI) -> impl Iterator<Item = &'a Path>
402+
fn input_files<'a, PI>(&self, source_paths: PI) -> Vec<PathBuf>
403403
where
404404
PI: IntoIterator<Item = &'a Path>,
405405
{
406406
let files = self.files();
407407
let include = self.include();
408408
let exclude = self.exclude();
409409

410-
let project_dir = self.project_dir.clone();
411-
source_paths.into_iter().filter_map(move |p| {
412-
// compute relative path in this project
413-
let p = match p.strip_prefix(&project_dir) {
414-
Ok(p) => p,
415-
Err(_) => return None,
416-
};
410+
source_paths
411+
.into_iter()
412+
.filter_map(move |p| {
413+
if !p.starts_with(&self.project_dir) {
414+
return None;
415+
}
417416

418-
// accept files in the file list
419-
for file in &files {
420-
if p == file {
421-
return Some(p);
417+
// normalize path
418+
let p = match NormalizedRelativePath::from_path(p) {
419+
Some(p) => p.into_path_buf(),
420+
None => return None,
421+
};
422+
423+
// accept files in the file list
424+
for file in &files {
425+
if &p == file {
426+
return Some(p);
427+
}
422428
}
423-
}
424429

425-
// reject files not in the include patterns
426-
if !include.iter().any(|i| i.matches_path(p)) {
427-
return None;
428-
}
430+
// reject files not in the include patterns
431+
if !include.iter().any(|i| i.matches_path(&p)) {
432+
return None;
433+
}
429434

430-
// reject files matching exclude patterns
431-
if exclude.iter().any(|e| e.matches_path(p)) {
432-
return None;
433-
}
435+
// reject files matching exclude patterns
436+
if exclude.iter().any(|e| e.matches_path(&p)) {
437+
return None;
438+
}
434439

435-
// file was included, and not excluded, so accept
436-
Some(p)
437-
})
440+
// file was included, and not excluded, so accept
441+
Some(p)
442+
})
443+
.collect()
438444
}
439445
}
440446

0 commit comments

Comments
 (0)