Skip to content

Commit

Permalink
improved padding when inserting at the end of a file
Browse files Browse the repository at this point in the history
  • Loading branch information
NiclasvanEyk committed Jun 7, 2023
1 parent 3e7598d commit 95e8bf2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/changelog/inserter.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func determineInsertionPoint(changeType ChangeType, changelog *Changelog) (int,
if len(changelog.Releases.Past) == 0 {
// We have an empty changelog with just the title:
// # Changelog <-- Add here
return changelog.Stop(), Padding{Before: 2, After: 0}
return changelog.Stop(), Padding{Before: 1, After: 0} // Only 1 Padding here, since it is reasonable to assume that the file already has a \n at the end
}

// We have some releases, but no next one:
Expand Down Expand Up @@ -163,7 +163,7 @@ func determineInsertionPoint(changeType ChangeType, changelog *Changelog) (int,
//
// ## [Unreleased] <-- Add after this line
if len(changelog.Releases.Past) == 0 {
return changelog.Stop(), Padding{Before: 2, After: 0}
return changelog.Stop(), Padding{Before: 1, After: 0} // Only 1 Padding here, since it is reasonable to assume that the file already has a \n at the end
}

latestRelease := changelog.Releases.Past[len(changelog.Releases.Past)-1]
Expand Down

0 comments on commit 95e8bf2

Please sign in to comment.