-
Notifications
You must be signed in to change notification settings - Fork 0
Add Truncate methods #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f92e076 to
8e2ca81
Compare
8e2ca81 to
3bc3975
Compare
|
bugbot run |
dd91ee1 to
d8ebcc5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds string and byte slice truncation methods that are grapheme-aware and account for display width, including support for optional tail strings (e.g., ellipsis).
Changes:
- Adds
TruncateStringandTruncateBytesfunctions with Options variants for grapheme-aware truncation by display width - Comprehensive test suite including unit tests, fuzz tests, cross-library comparison tests, and benchmarks
- Updated documentation including README benchmark results and compatibility analysis notes
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| width.go | Implements core truncation logic for strings and bytes with grapheme boundary handling |
| width_test.go | Extensive test cases covering edge cases, wide characters, emoji, and grapheme sequences |
| fuzz_test.go | Adds fuzzing for truncate functions and strengthens existing fuzz tests |
| comparison/benchmark_test.go | Benchmarks truncation performance with and without tails against go-runewidth |
| comparison/behavior_test.go | Cross-library behavioral comparison tests for truncation |
| comparison/README.md | Updated benchmark results including new truncation benchmarks |
| README.md | Updated benchmark results including new truncation benchmarks |
| comparison/COMPATIBILITY_ANALYSIS.md | Adds discussion about flag width handling in different terminals |
| .gitignore | Adds *.out pattern for Go test output files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TruncateString|Bytesis intended to truncate a string to a maximum display width, including the width of an optional tail (like an ellipsis, e.g.).Note
Introduces truncation by display width with optional tails and validates performance/behavior across libraries.
Options.TruncateString,TruncateString,Options.TruncateBytes, andTruncateBytesinwidth.go(grapheme-aware; tail width accounted)width_test.go, cross-lib comparisons incomparison/behavior_test.go, and fuzzing (FuzzTruncateStringAndBytes); strengthensFuzzBytesAndStringBenchmarkTruncateWithTailandBenchmarkTruncateWithoutTailincomparison/benchmark_test.go; updates benchmark outputs inREADME.mdandcomparison/README.md*.outto.gitignoreWritten by Cursor Bugbot for commit dd91ee1. Configure here.