diff --git a/crates/plotnik-lib/src/diagnostics/mod.rs b/crates/plotnik-lib/src/diagnostics/mod.rs index eee2f302..390783f4 100644 --- a/crates/plotnik-lib/src/diagnostics/mod.rs +++ b/crates/plotnik-lib/src/diagnostics/mod.rs @@ -146,12 +146,15 @@ impl Diagnostics { } } - self.messages + let mut result: Vec<_> = self + .messages .iter() .enumerate() .filter(|(i, _)| !suppressed[*i]) .map(|(_, m)| m.clone()) - .collect() + .collect(); + result.sort_by_key(|m| m.range.start()); + result } /// Raw access to all diagnostics (for debugging/testing). diff --git a/crates/plotnik-lib/src/query/mod_tests.rs b/crates/plotnik-lib/src/query/mod_tests.rs index 883e1299..06273236 100644 --- a/crates/plotnik-lib/src/query/mod_tests.rs +++ b/crates/plotnik-lib/src/query/mod_tests.rs @@ -37,14 +37,14 @@ fn combined_errors() { let q = Query::try_from("(call (Undefined) extra)").unwrap(); assert!(!q.is_valid()); insta::assert_snapshot!(q.dump_diagnostics(), @r" - error: bare identifier is not a valid expression; wrap in parentheses: `(identifier)` + error: `Undefined` is not defined | 1 | (call (Undefined) extra) - | ^^^^^ + | ^^^^^^^^^ - error: `Undefined` is not defined + error: bare identifier is not a valid expression; wrap in parentheses: `(identifier)` | 1 | (call (Undefined) extra) - | ^^^^^^^^^ + | ^^^^^ "); }