tamasfe / taplo

A TOML toolkit written in Rust
https://taplo.tamasfe.dev
MIT License
1.26k stars 108 forks source link

Bug: align entries fails when one entry is multiline #595

Open hbaxter-sc opened 2 months ago

hbaxter-sc commented 2 months ago

given a toml like this

[foo]
bar = 1
barbarbaz = { a = "b", c = "d" }
short = { short_key = "b", features = ["foo", "bar"] }

running taplo format t.toml --option align_entries=true gives:

[foo]
bar       = 1
barbarbaz = { a = "b", c = "d" }
short     = { short_key = "b", features = ["foo", "bar"] }

however, if an entry is put over multiple lines, then:

[foo]
bar = 1
barbarbaz = { a = "b", c = "d" }
long = { long_key_name_here = "b", another_long_key_name_here = "d", features = ["foo","bar",] }

the same command with align_entries=true gives:

[foo]
bar = 1
barbarbaz = { a = "b", c = "d" }
long = { long_key_name_here = "b", another_long_key_name_here = "d", features = [
  "foo",
  "bar",
] }

which does not have the entries aligned, we would expect something like:

[foo]
bar       = 1
barbarbaz = { a = "b", c = "d" }
long      = { long_key_name_here = "b", another_long_key_name_here = "d", features = [
               "foo",
               "bar",
             ] }