From c3c3ea9bfa7e6910136bbdcdc59f6d09860c6ab6 Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:37:22 -0300 Subject: [PATCH] allow same line decorator search no idea why this is needed but it is --- crates/typst-syntax/src/node.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/typst-syntax/src/node.rs b/crates/typst-syntax/src/node.rs index c784353e4..a658617d5 100644 --- a/crates/typst-syntax/src/node.rs +++ b/crates/typst-syntax/src/node.rs @@ -813,19 +813,18 @@ impl<'a> LinkedNode<'a> { } /// Get the first sibling decorator node at the line above this node. - /// This is done by moving backwards until the rightmost newline, and then - /// checking for decorators before the previous newline. + /// This is done by moving backwards, checking for decorators, until we hit + /// a second newline (that is, we only check, at most, the line before this + /// node). pub fn prev_attached_decorator(&self) -> Option { let mut cursor = self.prev_sibling_inner()?; let mut newlines = cursor.newlines(); let mut at_previous_line = false; while newlines < 2 { - if at_previous_line { - if cursor.kind() == SyntaxKind::Decorator { - // Decorators are attached if they're in a consecutive - // previous line. - return Some(cursor); - } + if cursor.kind() == SyntaxKind::Decorator { + // Decorators are attached if they're in a consecutive + // previous line. + return Some(cursor); } if newlines == 1 {