Skip to content

Read recent history from the end of the file - #104

Merged
Gubarz merged 1 commit into
cheatmd-dev:mainfrom
echo8134:fix/history-tail
Sep 30, 2026
Merged

Gubarz merged 1 commit into
cheatmd-dev:mainfrom
echo8134:fix/history-tail

Conversation

@echo8134

Copy link
Copy Markdown
Contributor

Summary

Loading a limited history parsed the entire file before truncation. Read regular files backward in bounded chunks until enough valid entries are found. Preserve newest-first ordering and the forward scanner for unlimited loads and nonregular files.

Related issues

No linked issue.

Verification

Public Load tests, bounded byte-count regression and real history picker checks pass. A five-iteration benchmark loads 1,000 entries from a 100,000-record file. Runtime drops from 82.49 ms to 1.68 ms, and allocated memory drops from 85.19 MB to 0.77 MB. Errors in older records outside the requested tail are intentionally unseen; recent line-size limits remain unchanged.

Local checks passed on Go 1.27.1. The CI workflow uses Go 1.26.3.

Checklist

  • go build ./... and go test ./... pass
  • gofmt -l . and go vet ./... are clean
  • Added regression tests for the changed behavior
  • cheatmd --lint examples/ passes
  • Docs/wiki changes are not needed for this fix

@Gubarz
Gubarz marked this pull request as ready for review September 30, 2026 21:03
@Gubarz
Gubarz merged commit 535e5eb into cheatmd-dev:main Sep 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants