diff --git a/editor/filter_vertical_formatter.go b/editor/filter_vertical_formatter.go index 7864d2d..2745072 100644 --- a/editor/filter_vertical_formatter.go +++ b/editor/filter_vertical_formatter.go @@ -62,6 +62,9 @@ func trimTrailingDuplicatedNewLine(tokens hclwrite.Tokens) hclwrite.Tokens { if tokens[end-1].Type == hclsyntax.TokenEOF { // skip EOF eof = tokens[end-1] + if tokens[end-2].Type != hclsyntax.TokenNewline { + break + } continue } if tokens[end-1].Type == hclsyntax.TokenNewline && diff --git a/editor/filter_vertical_formatter_test.go b/editor/filter_vertical_formatter_test.go index 7e69198..e5d7651 100644 --- a/editor/filter_vertical_formatter_test.go +++ b/editor/filter_vertical_formatter_test.go @@ -44,6 +44,12 @@ b1 { b2 l1 {} `, }, + { + name: "non-POSIX style end of file", + src: `a0 = v0`, + ok: true, + want: `a0 = v0`, + }, } for _, tc := range cases {