Skip to content

Commit

Permalink
Merge pull request #79 from Junya/fix-vertical-format
Browse files Browse the repository at this point in the history
Fix unexpected format when files do not end with newline
  • Loading branch information
minamijoyo authored Jun 12, 2023
2 parents 918a16d + 44bb74f commit 841dda9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions editor/filter_vertical_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
6 changes: 6 additions & 0 deletions editor/filter_vertical_formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 841dda9

Please sign in to comment.