Skip to content

Commit

Permalink
Merge pull request #42 from mfontanini/deferred-list-start-pause-fix
Browse files Browse the repository at this point in the history
Don't pop new line if list is not right after pause
  • Loading branch information
mfontanini authored Nov 6, 2023
2 parents 4d2fb62 + 8745138 commit 746d44e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ impl<'a> PresentationBuilder<'a> {
// other.
if matches!(last_chunk_operation, Some(RenderOperation::RenderLineBreak))
&& self.slide_state.last_chunk_ended_in_list
&& self.chunk_operations.is_empty()
{
self.slide_chunks.last_mut().unwrap().pop_last();
}
Expand Down Expand Up @@ -1247,6 +1248,30 @@ mod test {
assert_eq!(lines, expected_lines);
}

#[test]
fn pause_after_list() {
let elements = vec![
MarkdownElement::List(vec![ListItem {
depth: 0,
contents: "one".into(),
item_type: ListItemType::OrderedPeriod,
}]),
build_pause(),
MarkdownElement::Heading { level: 1, text: "hi".into() },
MarkdownElement::List(vec![ListItem {
depth: 0,
contents: "two".into(),
item_type: ListItemType::OrderedPeriod,
}]),
];
let slides = build_presentation(elements).into_slides();
let first_chunk = &slides[0];
let operations = first_chunk.iter_operations().collect::<Vec<_>>();
// This is pretty easy to break, refactor soon
let last_operation = &operations[operations.len() - 4];
assert!(matches!(last_operation, RenderOperation::RenderLineBreak), "last operation is {last_operation:?}");
}

#[rstest]
#[case::multiline("hello\nworld")]
#[case::many_open_braces("{{{")]
Expand Down
2 changes: 1 addition & 1 deletion src/presenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub enum PresentationError {
Render(#[from] RenderError),

#[error(transparent)]
LoadPresentationError(#[from] LoadPresentationError),
LoadPresentation(#[from] LoadPresentationError),

#[error("io: {0}")]
Io(#[from] io::Error),
Expand Down

0 comments on commit 746d44e

Please sign in to comment.