summaryrefslogtreecommitdiff
path: root/src/layout/tree.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-08-29 12:02:07 +0200
committerLaurenz <laurmaedje@gmail.com>2020-08-29 12:02:07 +0200
commit236750c35fbad916b63774df917cbc436f1d1a8c (patch)
treec6e837da340f50ad64bf182d676e7228c044f08d /src/layout/tree.rs
parent6febc0327304451bc956985b7cadb07a0b563c79 (diff)
Remove par nodes in favor of parbreaks 🔄
This basically reverts the earlier change from parbreaks to par nodes because: - It is simpler and less nested - It works way better with functions that layout their body inline like `font`, which where buggy before, previously The original reasons for changing to par nodes were: - the envisioned design of the layouter at that time (based on dynamic nodes etc.), which is not relevant anymore - possibly existing benefits with regards to incremental compilation, which are unsure and outweighed by the immediate benefits of the parbreak-representation
Diffstat (limited to 'src/layout/tree.rs')
-rw-r--r--src/layout/tree.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/layout/tree.rs b/src/layout/tree.rs
index e500c4ba..adc179bc 100644
--- a/src/layout/tree.rs
+++ b/src/layout/tree.rs
@@ -63,6 +63,10 @@ impl<'a> TreeLayouter<'a> {
match &node.v {
SyntaxNode::Spacing => self.layout_space(),
SyntaxNode::Linebreak => self.layouter.finish_line(),
+ SyntaxNode::Parbreak => self.layouter.add_secondary_spacing(
+ self.style.text.paragraph_spacing(),
+ SpacingKind::PARAGRAPH,
+ ),
SyntaxNode::ToggleItalic => {
self.style.text.italic = !self.style.text.italic;
@@ -80,7 +84,6 @@ impl<'a> TreeLayouter<'a> {
}
SyntaxNode::Raw(lines) => self.layout_raw(lines).await,
- SyntaxNode::Par(par) => self.layout_par(par).await,
SyntaxNode::Call(call) => {
self.layout_call(Spanned::new(call, node.span)).await;
}
@@ -128,14 +131,6 @@ impl<'a> TreeLayouter<'a> {
self.style.text.fallback = fallback;
}
- async fn layout_par(&mut self, par: &SyntaxTree) {
- self.layout_tree(par).await;
- self.layouter.add_secondary_spacing(
- self.style.text.paragraph_spacing(),
- SpacingKind::PARAGRAPH,
- );
- }
-
async fn layout_call(&mut self, call: Spanned<&CallExpr>) {
let ctx = LayoutContext {
style: &self.style,