Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add extra line breaks in markdown lists #2689

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion helix-term/src/ui/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ impl Markdown {
Event::Start(Tag::List(list)) => list_stack.push(list),
Event::End(Tag::List(_)) => {
list_stack.pop();
// whenever list closes, new line
lines.push(Spans::default());
}
Event::Start(Tag::Item) => {
tags.push(Tag::Item);
Expand All @@ -186,11 +188,19 @@ impl Markdown {
| Tag::Paragraph
| Tag::CodeBlock(CodeBlockKind::Fenced(_))
| Tag::Item => {
// whenever code block or paragraph closes, new line
let spans = std::mem::take(&mut spans);
if !spans.is_empty() {
lines.push(Spans::from(spans));
}
}
_ => (),
}

// whenever heading, code block or paragraph closes, new line
match tag {
Tag::Heading(_, _, _)
| Tag::Paragraph
| Tag::CodeBlock(CodeBlockKind::Fenced(_)) => {
lines.push(Spans::default());
}
_ => (),
Expand Down