refactor: simplify pin_entry (#320)

* refactor: simplify pin_entry

* fix: update self.pinning
This commit is contained in:
QuarticCat 2024-05-31 14:52:32 +08:00 committed by GitHub
parent 257a6bcb86
commit 27fa1beb26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,17 +31,10 @@ impl TypstLanguageServer {
/// Pin the entry to the given path
pub fn pin_entry(&mut self, new_entry: Option<ImmutPath>) -> Result<(), Error> {
self.pinning = new_entry.is_some();
self.primary.do_change_entry(new_entry)?;
if !self.pinning {
let fallback = self.config.compile.determine_default_entry_path();
let fallback = fallback.or_else(|| self.focusing.clone());
if let Some(e) = fallback {
self.primary.do_change_entry(Some(e))?;
}
}
Ok(())
let entry = new_entry
.or_else(|| self.config.compile.determine_default_entry_path())
.or_else(|| self.focusing.clone());
self.primary.do_change_entry(entry).map(|_| ())
}
/// Updates the primary (focusing) entry