Skip to content

Commit

Permalink
πŸ› panic against empty file with eof_newline feature, resolves: #196 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Shion1305 authored Jul 17, 2024
1 parent 6dd7bbb commit 2cdff15
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/features/eof_newline.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func MakeFeatureEOFNewline(linebreakStr string) yamlfmt.Feature {
func eofNewlineFeature(linebreakStr string) yamlfmt.FeatureFunc {
return func(content []byte) ([]byte, error) {
// This check works in both linebreak modes.
if content[len(content)-1] != '\n' {
if len(content) == 0 || content[len(content)-1] != '\n' {
linebreakBytes := []byte(linebreakStr)
content = append(content, linebreakBytes...)
}
Expand Down

0 comments on commit 2cdff15

Please sign in to comment.