diff options
author | Frojdholm | 2022-06-08 00:44:07 +0000 |
---|---|---|
committer | GitHub | 2022-06-08 00:44:07 +0000 |
commit | e0532771cc3503afcbfb5cd5d45b8c57462587f9 (patch) | |
tree | 166fe0554e788b7c19d77ec238dc0c2ae98c614c /helix-term/src | |
parent | 4a27e2d93846f3b66ab0dc225e65d2fb869463f3 (diff) |
Do not add extra line breaks in markdown lists (#2689)
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/ui/markdown.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs index 5f78c3cc..45273002 100644 --- a/helix-term/src/ui/markdown.rs +++ b/helix-term/src/ui/markdown.rs @@ -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); @@ -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()); } _ => (), |