diff --git a/cmd/show.go b/cmd/show.go index 4fe32e0..7e20cd1 100644 --- a/cmd/show.go +++ b/cmd/show.go @@ -61,7 +61,6 @@ var showCmd = &cobra.Command{ } changelog := clog.Parse(source) - // TODO: These bounds are always off by two (too much) at the Stop bounds, err := findReleaseBounds(args[0], &changelog) if err != nil { return err diff --git a/internal/changelog/inserter.go b/internal/changelog/inserter.go index 1486a86..dbe52fd 100644 --- a/internal/changelog/inserter.go +++ b/internal/changelog/inserter.go @@ -160,7 +160,7 @@ func determineInsertionPoint(changeType ChangeType, changelog *Changelog) (int, } latestRelease := changelog.Releases.Past[len(changelog.Releases.Past)-1] - return latestRelease.Begin, Padding{Before: 0, After: 2} + return latestRelease.Bounds.Start, Padding{Before: 0, After: 2} } // Now with all other edge cases handled we can shift our focus to adding a diff --git a/internal/changelog/parser.go b/internal/changelog/parser.go index 716cccf..c9e19a1 100644 --- a/internal/changelog/parser.go +++ b/internal/changelog/parser.go @@ -49,10 +49,7 @@ type Release struct { Version string HeadlineBounds Bounds - - // Position of the first character of the release block (the heading) - Begin int - Bounds Bounds + Bounds Bounds } func NewRelease(version string, date string) Release { @@ -189,17 +186,18 @@ func Parse(source []byte) Changelog { if heading.Level == 2 { headingBounds := ComputeBounds(heading) if currentRelease != nil { + stop := headingBounds.Start - 3 if currentReleaseIsNextRelease { nextRelease = &NextRelease{ Bounds: Bounds{ Start: currentRelease.HeadlineBounds.Start - 3, - Stop: headingBounds.Start - 1, + Stop: stop, }, HeadlineBounds: currentRelease.HeadlineBounds, Sections: currentRelease.Sections, } } else { - currentRelease.Bounds.Stop = headingBounds.Start - 1 + currentRelease.Bounds.Stop = stop releases = append(releases, *currentRelease) } }