mirror of
https://github.com/typst/typst
synced 2025-05-15 01:25:28 +08:00
Do not surface warnings from non-last layout iterations (#4970)
This commit is contained in:
parent
16e67f8bea
commit
ea145ff33b
@ -156,6 +156,11 @@ impl Sink {
|
|||||||
pub fn values(self) -> EcoVec<(Value, Option<Styles>)> {
|
pub fn values(self) -> EcoVec<(Value, Option<Styles>)> {
|
||||||
self.values
|
self.values
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extend from another sink.
|
||||||
|
pub fn extend_from_sink(&mut self, other: Sink) {
|
||||||
|
self.extend(other.delayed, other.warnings, other.values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[comemo::track]
|
#[comemo::track]
|
||||||
@ -181,7 +186,7 @@ impl Sink {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extend from another sink.
|
/// Extend from parts of another sink.
|
||||||
fn extend(
|
fn extend(
|
||||||
&mut self,
|
&mut self,
|
||||||
delayed: EcoVec<SourceDiagnostic>,
|
delayed: EcoVec<SourceDiagnostic>,
|
||||||
|
@ -128,6 +128,7 @@ fn compile_impl(
|
|||||||
.content();
|
.content();
|
||||||
|
|
||||||
let mut iter = 0;
|
let mut iter = 0;
|
||||||
|
let mut subsink;
|
||||||
let mut document = Document::default();
|
let mut document = Document::default();
|
||||||
|
|
||||||
// Relayout until all introspections stabilize.
|
// Relayout until all introspections stabilize.
|
||||||
@ -138,15 +139,14 @@ fn compile_impl(
|
|||||||
&["layout (1)", "layout (2)", "layout (3)", "layout (4)", "layout (5)"];
|
&["layout (1)", "layout (2)", "layout (3)", "layout (4)", "layout (5)"];
|
||||||
let _scope = TimingScope::new(ITER_NAMES[iter], None);
|
let _scope = TimingScope::new(ITER_NAMES[iter], None);
|
||||||
|
|
||||||
// Clear delayed errors.
|
subsink = Sink::new();
|
||||||
sink.delayed();
|
|
||||||
|
|
||||||
let constraint = <Introspector as Validate>::Constraint::new();
|
let constraint = <Introspector as Validate>::Constraint::new();
|
||||||
let mut engine = Engine {
|
let mut engine = Engine {
|
||||||
world,
|
world,
|
||||||
introspector: document.introspector.track_with(&constraint),
|
introspector: document.introspector.track_with(&constraint),
|
||||||
traced,
|
traced,
|
||||||
sink: sink.track_mut(),
|
sink: subsink.track_mut(),
|
||||||
route: Route::default(),
|
route: Route::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ fn compile_impl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if iter >= 5 {
|
if iter >= 5 {
|
||||||
sink.warn(warning!(
|
subsink.warn(warning!(
|
||||||
Span::detached(), "layout did not converge within 5 attempts";
|
Span::detached(), "layout did not converge within 5 attempts";
|
||||||
hint: "check if any states or queries are updating themselves"
|
hint: "check if any states or queries are updating themselves"
|
||||||
));
|
));
|
||||||
@ -168,6 +168,8 @@ fn compile_impl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sink.extend_from_sink(subsink);
|
||||||
|
|
||||||
// Promote delayed errors.
|
// Promote delayed errors.
|
||||||
let delayed = sink.delayed();
|
let delayed = sink.delayed();
|
||||||
if !delayed.is_empty() {
|
if !delayed.is_empty() {
|
||||||
|
@ -76,3 +76,16 @@
|
|||||||
// Warning: 2-44 `counter.display` without context is deprecated
|
// Warning: 2-44 `counter.display` without context is deprecated
|
||||||
// Hint: 2-44 use it in a `context` expression instead
|
// Hint: 2-44 use it in a `context` expression instead
|
||||||
#counter(heading).display(n => test(n, 10))
|
#counter(heading).display(n => test(n, 10))
|
||||||
|
|
||||||
|
--- context-delayed-warning ---
|
||||||
|
// Ensure that the warning that triggers in the first layout iteration is not
|
||||||
|
// surfaced since it goes away in the second one. Just like errors in show
|
||||||
|
// rules.
|
||||||
|
#show heading: none
|
||||||
|
|
||||||
|
= A <a>
|
||||||
|
#context {
|
||||||
|
let n = query(<a>).len()
|
||||||
|
let fonts = ("nope", "Roboto")
|
||||||
|
set text(font: fonts.at(n))
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user