From 6257e4d6cf060f367c3f2eb2d005a091b6432e88 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 10 Oct 2024 13:59:00 +0200 Subject: More robust glyph drawing (#5159) --- crates/typst-syntax/src/span.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/typst-syntax/src/span.rs') diff --git a/crates/typst-syntax/src/span.rs b/crates/typst-syntax/src/span.rs index 4d5dd9c3..85745f60 100644 --- a/crates/typst-syntax/src/span.rs +++ b/crates/typst-syntax/src/span.rs @@ -92,6 +92,13 @@ impl Span { } } + /// Find the first non-detached span in the iterator. + pub fn find(iter: impl IntoIterator) -> Self { + iter.into_iter() + .find(|span| !span.is_detached()) + .unwrap_or(Span::detached()) + } + /// Resolve a file location relative to this span's source. pub fn resolve_path(self, path: &str) -> Result { let Some(file) = self.id() else { -- cgit v1.2.3