summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPgBiel <9021226+PgBiel@users.noreply.github.com>2024-06-20 23:37:22 -0300
committerPgBiel <9021226+PgBiel@users.noreply.github.com>2024-06-26 12:17:53 -0300
commitc3c3ea9bfa7e6910136bbdcdc59f6d09860c6ab6 (patch)
tree43c88fb6e1573647fa01f927191658cf2185225b
parenta1d5861a58d2b4f2b9fdf753ade8c2b5c3d7fbbd (diff)
allow same line decorator search
no idea why this is needed but it is
-rw-r--r--crates/typst-syntax/src/node.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/typst-syntax/src/node.rs b/crates/typst-syntax/src/node.rs
index c784353e..a658617d 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<Self> {
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 {