From 3c94e05cedcb308d83028bfb42e19b29c1201ac1 Mon Sep 17 00:00:00 2001 From: bluebear94 Date: Wed, 2 Aug 2023 18:24:25 -0400 Subject: Warn if layout doesn't stabilize (#1684) --- crates/typst/src/model/mod.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/typst/src/model/mod.rs b/crates/typst/src/model/mod.rs index cab1f71f..d839422a 100644 --- a/crates/typst/src/model/mod.rs +++ b/crates/typst/src/model/mod.rs @@ -28,7 +28,7 @@ use std::mem::ManuallyDrop; use comemo::{Track, Tracked, TrackedMut, Validate}; -use crate::diag::{SourceDiagnostic, SourceResult}; +use crate::diag::{warning, SourceDiagnostic, SourceResult}; use crate::doc::Document; use crate::eval::Tracer; use crate::World; @@ -82,7 +82,20 @@ pub fn typeset( introspector = ManuallyDrop::new(Introspector::new(&document.pages)); iter += 1; - if iter >= 5 || introspector.validate(&constraint) { + if introspector.validate(&constraint) { + break; + } + + if iter >= 5 { + tracer.warn( + warning!( + world.main().root().span(), + "layout did not converge within 5 attempts", + ) + .with_hint( + "check if any states or queries are updating themselves".into(), + ), + ); break; } } -- cgit v1.2.3