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

hclwrite: Do not add spaces before TokenTemplateControl #125

Closed wata727 closed 4 years ago

wata727 commented 4 years ago

Fixes https://github.com/hashicorp/terraform/issues/22356

If we format the following code, will get the following results:

input

"%{if true}${var.foo}%{endif}"

result

"%{if true}${var.foo} %{endif}"

This is a different string, so do not add a space before the %{. This pull request changes the handling of TokenTemplateControl token to avoid adding an extra space.

codecov-io commented 4 years ago

Codecov Report

Merging #125 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #125   +/-   ##
=======================================
  Coverage   69.03%   69.03%           
=======================================
  Files          98       98           
  Lines       10307    10307           
=======================================
  Hits         7115     7115           
  Misses       2867     2867           
  Partials      325      325
Impacted Files Coverage Δ
hclwrite/format.go 95.37% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 65731f3...2ef8aa0. Read the comment docs.

apparentlymart commented 4 years ago

Thanks @wata727! Looks good to me. :tada: