l command: honor the -l wrap width - #552
Conversation
The l command ignored -l N and instead took its wrap width from terminal_size(). As a result, output depended on the terminal size and differed between a pipe and a tty. Use ProcessingContext::length, which already defaults to 70. GNU sed calls the option -l N, --line-length=N, while we exposed it as --length. Add --line-length and retain --length as a hidden alias for compatibility. A width of 0 means never wrap. In that case, ListLine now periodically flushes its buffer instead of accumulating the entire rendered line. Add OutputBuffer::write_partial_str for these partial writes, since write_str may defer a trailing newline. This removes the crate's last direct use of terminal_size, so drop the direct dependency from [dependencies] and [workspace.dependencies]. The package remains in the dependency tree through clap_builder and textwrap.
|
GNU sed testsuite comparison: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #552 +/- ##
==========================================
+ Coverage 83.04% 83.05% +0.01%
==========================================
Files 13 13
Lines 7046 6946 -100
Branches 401 403 +2
==========================================
- Hits 5851 5769 -82
+ Misses 1192 1174 -18
Partials 3 3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 12.14%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | number_fix |
1.1 s | 1.3 s | -12.14% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing SichenLiang:fix-l-command-wrap-width (e1e8e53) with main (77f442d)
Fixes #551.
Out of scope and unchanged here: how
lrenders a newline inside the pattern space, and--posixaccepting thel nargument. GNU also derives the default width from aCOLSenvironment variable; its manual does not document that, so this implements the documented default of 70.