diff options
| author | PgBiel <9021226+PgBiel@users.noreply.github.com> | 2024-06-13 22:40:55 -0300 |
|---|---|---|
| committer | PgBiel <9021226+PgBiel@users.noreply.github.com> | 2024-06-26 12:17:53 -0300 |
| commit | e69c58a2345cf819967dd2261116ffe9771cfd7e (patch) | |
| tree | 0d36671043d4a3c6cca69c2b548965db4c983f57 | |
| parent | 26ae1d3c2768efcbb14be980ad0455c3640d0694 (diff) | |
fix decorator lookup next to the span itself
| -rw-r--r-- | crates/typst/src/engine.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/crates/typst/src/engine.rs b/crates/typst/src/engine.rs index 09772e17..0608485a 100644 --- a/crates/typst/src/engine.rs +++ b/crates/typst/src/engine.rs @@ -261,12 +261,14 @@ fn check_warning_suppressed( // The source must exist if a warning occurred in the file, // or has a tracepoint in the file. let source = world.source(file).unwrap(); - // The span must point to this source file, so we unwrap. - let mut node = &source.find(span).unwrap(); - // Walk the parent nodes to check for a warning suppression. - while let Some(parent) = node.parent() { - if let Some(sibling) = parent.prev_attached_comment() { + let search_root = source.find(span); + let mut searched_node = search_root.as_ref(); + + // Walk the parent nodes to check for a warning suppression in the + // previous line. + while let Some(node) = searched_node { + if let Some(sibling) = node.prev_attached_comment() { if let Some(comment) = sibling.cast::<ast::LineComment>() { if matches!(parse_warning_suppression(comment.content()), Some(suppressed) if identifier.name() == suppressed) { @@ -274,7 +276,7 @@ fn check_warning_suppressed( } } } - node = parent; + searched_node = node.parent(); } false |
