Bound project index scans to the requested directory subtree
This commit is contained in:
1 parent
0f1b0f5978
commit
1a2379a6c2
1 file changed
+20
-6
@@ -1,7 +1,9 @@
|
||||
//! Editor-owned immutable logical inputs. Construction and lookup never consult
|
||||
//! the filesystem. Live generated I/O is an explicit, separate host contract.
|
||||
use super::*;
|
||||
use std::{collections::VecDeque, ffi::OsString, path::Component, sync::OnceLock};
|
||||
use std::{
|
||||
collections::VecDeque, ffi::OsString, ops::Bound, path::Component, sync::OnceLock,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ProjectDefinition {
|
||||
@@ -551,15 +553,27 @@ impl ProjectSnapshot {
|
||||
continue;
|
||||
}
|
||||
ancestors.push(location.path.clone());
|
||||
let parent = location.path.as_path();
|
||||
// Component ordering keeps a directory's descendants contiguous
|
||||
// in each collection. Keep the direct-parent check for children.
|
||||
let bounds = (Bound::Included(parent), Bound::Unbounded);
|
||||
let in_subtree = |child: &&PathBuf| child.starts_with(parent);
|
||||
let mut names = BTreeSet::new();
|
||||
for child in self
|
||||
.files
|
||||
.keys()
|
||||
.chain(&self.directories)
|
||||
.chain(self.aliases.keys())
|
||||
.chain(live)
|
||||
.range::<Path, _>(bounds)
|
||||
.map(|(path, _)| path)
|
||||
.take_while(in_subtree)
|
||||
.chain(self.directories.range::<Path, _>(bounds).take_while(in_subtree))
|
||||
.chain(
|
||||
self.aliases
|
||||
.range::<Path, _>(bounds)
|
||||
.map(|(path, _)| path)
|
||||
.take_while(in_subtree),
|
||||
)
|
||||
.chain(live.range::<Path, _>(bounds).take_while(in_subtree))
|
||||
{
|
||||
if child.parent() == Some(location.path.as_path()) {
|
||||
if child.parent() == Some(parent) {
|
||||
if let Some(name) = child.file_name() {
|
||||
names.insert(name.to_owned());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user