dev: use DETACHED_ENTRY if no entry is provided (#647)

* dev: use `DETACHED_ENTRY` if no entry is provided

* fix: compile error
This commit is contained in:
Myriad-Dreamin 2024-10-09 14:39:24 +08:00 committed by GitHub
parent 2334593ec4
commit c9846b1d0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -551,7 +551,7 @@ impl CompileConfig {
}
/// Determines the root directory for the entry file.
fn determine_root(&self, entry: Option<&ImmutPath>) -> Option<ImmutPath> {
pub fn determine_root(&self, entry: Option<&ImmutPath>) -> Option<ImmutPath> {
if let Some(path) = &self.root_path {
return Some(path.as_path().into());
}

View file

@ -1018,7 +1018,11 @@ impl LanguageState {
let handle = client.handle.clone();
let entry = query
.associated_path()
.map(|path| client.config.determine_entry(Some(path.into())));
.map(|path| client.config.determine_entry(Some(path.into())))
.or_else(|| {
let root = client.config.determine_root(None)?;
Some(EntryState::new_rooted(root, Some(*DETACHED_ENTRY)))
});
just_future(async move {
let mut snap = snap.receive().await?;