From 211b546e4e4c75caaa6ee31493d52802b898aa2a Mon Sep 17 00:00:00 2001 From: Johann Birnick <6528009+jbirnick@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:02:04 +0200 Subject: Fixes counter stepping behavior (#4631) Co-authored-by: Laurenz --- crates/typst/src/introspection/counter.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'crates') diff --git a/crates/typst/src/introspection/counter.rs b/crates/typst/src/introspection/counter.rs index 2aefb68e..b9462e3d 100644 --- a/crates/typst/src/introspection/counter.rs +++ b/crates/typst/src/introspection/counter.rs @@ -685,14 +685,12 @@ impl CounterState { pub fn step(&mut self, level: NonZeroUsize, by: usize) { let level = level.get(); - if self.0.len() >= level { - self.0[level - 1] = self.0[level - 1].saturating_add(by); - self.0.truncate(level); - } - while self.0.len() < level { - self.0.push(1); + self.0.push(0); } + + self.0[level - 1] = self.0[level - 1].saturating_add(by); + self.0.truncate(level); } /// Get the first number of the state. -- cgit v1.2.3