Skip to content

Commit

Permalink
Reset list state once they are done
Browse files Browse the repository at this point in the history
Discovered in the repeating pattern of the scroll example where it would
end up being two newlines before the lists.
  • Loading branch information
lampsitter committed Sep 7, 2024
1 parent 0eea543 commit d396190
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions egui_commonmark/src/parsers/pulldown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
5 changes: 5 additions & 0 deletions egui_commonmark_macros/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d396190

Please sign in to comment.