mirror of
https://github.com/typst/typst
synced 2025-05-20 03:55:29 +08:00
allow same line decorator search
no idea why this is needed but it is
This commit is contained in:
parent
a1d5861a58
commit
c3c3ea9bfa
@ -813,19 +813,18 @@ impl<'a> LinkedNode<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the first sibling decorator node at the line above this node.
|
/// Get the first sibling decorator node at the line above this node.
|
||||||
/// This is done by moving backwards until the rightmost newline, and then
|
/// This is done by moving backwards, checking for decorators, until we hit
|
||||||
/// checking for decorators before the previous newline.
|
/// a second newline (that is, we only check, at most, the line before this
|
||||||
|
/// node).
|
||||||
pub fn prev_attached_decorator(&self) -> Option<Self> {
|
pub fn prev_attached_decorator(&self) -> Option<Self> {
|
||||||
let mut cursor = self.prev_sibling_inner()?;
|
let mut cursor = self.prev_sibling_inner()?;
|
||||||
let mut newlines = cursor.newlines();
|
let mut newlines = cursor.newlines();
|
||||||
let mut at_previous_line = false;
|
let mut at_previous_line = false;
|
||||||
while newlines < 2 {
|
while newlines < 2 {
|
||||||
if at_previous_line {
|
if cursor.kind() == SyntaxKind::Decorator {
|
||||||
if cursor.kind() == SyntaxKind::Decorator {
|
// Decorators are attached if they're in a consecutive
|
||||||
// Decorators are attached if they're in a consecutive
|
// previous line.
|
||||||
// previous line.
|
return Some(cursor);
|
||||||
return Some(cursor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if newlines == 1 {
|
if newlines == 1 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user