diff --git a/crates/taplo/src/formatter/mod.rs b/crates/taplo/src/formatter/mod.rs index 7fa8eb356..22d04f59e 100644 --- a/crates/taplo/src/formatter/mod.rs +++ b/crates/taplo/src/formatter/mod.rs @@ -681,7 +681,6 @@ fn add_entries( entry.value.clear(); if let Some(c) = value.trailing_comment() { - debug_assert!(entry.comment.is_none()); entry.comment = Some(c); } diff --git a/crates/taplo/src/tests/formatter.rs b/crates/taplo/src/tests/formatter.rs index f015e715f..1d7efb902 100644 --- a/crates/taplo/src/tests/formatter.rs +++ b/crates/taplo/src/tests/formatter.rs @@ -1,6 +1,7 @@ use difference::Changeset; use crate::formatter; +use crate::formatter::Options; macro_rules! assert_format { ($expected:expr, $actual:expr) => { @@ -1164,3 +1165,21 @@ my_array = [ assert_format!(expected, &formatted); } + +#[test] +fn test_comment_after_entry() { + let src = r#" +a = "b" # comment +"#; + + let expected = r#" +a = "b" # comment +"#; + let opt = Options { + column_width: 1, + ..Default::default() + }; + let formatted = crate::formatter::format(src, opt); + + assert_format!(expected, &formatted); +}