mirror of
https://github.com/typst/typst
synced 2025-05-17 02:25:27 +08:00
remove inner node 'capped_newlines' field
This commit is contained in:
parent
629375a981
commit
2b442eae5e
@ -161,7 +161,17 @@ impl SyntaxNode {
|
|||||||
Repr::Leaf(_) | Repr::Error(_) => {
|
Repr::Leaf(_) | Repr::Error(_) => {
|
||||||
crate::lexer::count_capped_newlines(self.text())
|
crate::lexer::count_capped_newlines(self.text())
|
||||||
}
|
}
|
||||||
Repr::Inner(inner) => inner.capped_newlines,
|
Repr::Inner(inner) => {
|
||||||
|
let mut newlines = 0;
|
||||||
|
for child in &inner.children {
|
||||||
|
newlines += child.capped_newlines();
|
||||||
|
if newlines >= 2 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newlines.min(2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,11 +408,6 @@ struct InnerNode {
|
|||||||
descendants: usize,
|
descendants: usize,
|
||||||
/// Whether this node or any of its children are erroneous.
|
/// Whether this node or any of its children are erroneous.
|
||||||
erroneous: bool,
|
erroneous: bool,
|
||||||
/// The (capped) amount of newlines in this node's descendants.
|
|
||||||
/// This is solely used to tell whether this node contains 0, 1, 2 or more
|
|
||||||
/// newlines. As such, this number is capped at 2, even though there may be
|
|
||||||
/// more newlines inside this node.
|
|
||||||
capped_newlines: u8,
|
|
||||||
/// The upper bound of this node's numbering range.
|
/// The upper bound of this node's numbering range.
|
||||||
upper: u64,
|
upper: u64,
|
||||||
/// This node's children, losslessly make up this node.
|
/// This node's children, losslessly make up this node.
|
||||||
@ -418,23 +423,17 @@ impl InnerNode {
|
|||||||
let mut len = 0;
|
let mut len = 0;
|
||||||
let mut descendants = 1;
|
let mut descendants = 1;
|
||||||
let mut erroneous = false;
|
let mut erroneous = false;
|
||||||
let mut capped_newlines: u8 = 0;
|
|
||||||
|
|
||||||
for child in &children {
|
for child in &children {
|
||||||
len += child.len();
|
len += child.len();
|
||||||
descendants += child.descendants();
|
descendants += child.descendants();
|
||||||
erroneous |= child.erroneous();
|
erroneous |= child.erroneous();
|
||||||
|
|
||||||
if capped_newlines < 2 {
|
|
||||||
capped_newlines = capped_newlines.saturating_add(child.capped_newlines());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
kind,
|
kind,
|
||||||
len,
|
len,
|
||||||
span: Span::detached(),
|
span: Span::detached(),
|
||||||
capped_newlines: capped_newlines.min(2),
|
|
||||||
descendants,
|
descendants,
|
||||||
erroneous,
|
erroneous,
|
||||||
upper: 0,
|
upper: 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user