summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbluebear94 <uruwi@protonmail.com>2023-08-02 18:24:25 -0400
committerGitHub <noreply@github.com>2023-08-03 00:24:25 +0200
commit3c94e05cedcb308d83028bfb42e19b29c1201ac1 (patch)
tree2edfa0b8b928d3ad63e26a7aa2a73ec7aa1979a8 /crates
parent77cc05b121bef5a7feb62345d19d9c693415d7cd (diff)
Warn if layout doesn't stabilize (#1684)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/model/mod.rs17
1 files changed, 15 insertions, 2 deletions
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;
}
}