Skip to content

Commit dedd9cf

Browse files
ryan-phslewiskelly
andauthored
[hcledit/create] simplify comment creation in block handler
Co-authored-by: Scott Lewis-Kelly <[email protected]>
1 parent c657a2d commit dedd9cf

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

internal/handler/block.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ func newBlockHandler(labels []string, comment string) (Handler, error) {
2626
}
2727

2828
func (h *blockHandler) HandleBody(body *hclwrite.Body, name string, _ []string) error {
29-
if h.comment != "" {
30-
if !strings.HasPrefix(h.comment, "//") {
31-
h.comment = fmt.Sprintf("// %s", h.comment)
32-
}
33-
tokens := beforeTokens(h.comment, false)
34-
body.AppendUnstructuredTokens(tokens)
35-
}
29+
body.AppendUnstructuredTokens(beforeTokens(fmt.Sprintf("// %s", strings.TrimSpace(strings.TrimPrefix(h.comment, "//"))), false))
3630

3731
body.AppendNewBlock(name, h.labels)
3832
return nil

0 commit comments

Comments
 (0)