hashicorp / hcl2

Former temporary home for experimental new version of HCL
https://github.com/hashicorp/hcl
Mozilla Public License 2.0
373 stars 66 forks source link

Formatter uses incorrect spacing for `for` expression constructs #52

Closed apparentlymart closed 5 years ago

apparentlymart commented 5 years ago

Given a for expression like this:

  for_each = [for x in [var.versioning]: x if x.enabled]

...the auto-formatter will shuffle the spacing around incorrectly like this:

  for_each = [for x in[var.versioning] : x if x.enabled]

The extra space before the colon should be easy to address. The space after the in keyword may be trickier, since to the formatting rules it looks like an index expression against an identifier in. The formatter might need a special case for this one as a result.