From d39619076e7a966229f4b64053cf6e6f8b6f96f3 Mon Sep 17 00:00:00 2001 From: Erlend Walstad <96946613+lampsitter@users.noreply.github.com> Date: Sat, 7 Sep 2024 16:58:32 +0200 Subject: [PATCH] Reset list state once they are done Discovered in the repeating pattern of the scroll example where it would end up being two newlines before the lists. --- egui_commonmark/src/parsers/pulldown.rs | 5 +++++ egui_commonmark_macros/src/generator.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/egui_commonmark/src/parsers/pulldown.rs b/egui_commonmark/src/parsers/pulldown.rs index 1ad4f29..74ac831 100644 --- a/egui_commonmark/src/parsers/pulldown.rs +++ b/egui_commonmark/src/parsers/pulldown.rs @@ -684,6 +684,11 @@ impl CommonMarkViewerInternal { self.line.should_end_newline = true; self.list.end_level(ui, self.line.can_insert_end()); + + if !self.list.is_inside_a_list() { + // Reset all the state and make it ready for the next list that occurs + self.list = List::default(); + } } pulldown_cmark::TagEnd::Item => {} pulldown_cmark::TagEnd::FootnoteDefinition => { diff --git a/egui_commonmark_macros/src/generator.rs b/egui_commonmark_macros/src/generator.rs index 0a54a4e..534fc81 100644 --- a/egui_commonmark_macros/src/generator.rs +++ b/egui_commonmark_macros/src/generator.rs @@ -714,6 +714,11 @@ impl CommonMarkViewerInternal { pulldown_cmark::TagEnd::List(_) => { let s = self.list.end_level(self.line.can_insert_end()); + if !self.list.is_inside_a_list() { + // Reset all the state and make it ready for the next list that occurs + self.list = List::default(); + } + self.line.should_start_newline = true; self.line.should_end_newline = true; s