Conversation
Implements POSIX.1-2024 requirements for vi/ex terminal sizing: - Honor COLUMNS and LINES environment variables per POSIX spec - Environment variables override ioctl values when set and valid - Fall back to ioctl or defaults when env vars are unset/invalid - Maintain safety bounds (clamping) after applying overrides Implements visual line wrapping per POSIX requirements: - Long lines are folded across multiple display rows - Replaces previous truncation behavior with proper wrapping - Handles tabs and control characters correctly during wrapping - Cursor positioning works correctly with wrapped lines Added comprehensive test coverage: - 4 tests for COLUMNS/LINES environment variable behavior - 4 tests for line wrapping functionality - All 381 tests pass with zero clippy warnings Fixes #549
There was a problem hiding this comment.
Pull request overview
This PR extends pax list formatting and improves the vi terminal UI to be more POSIX-compliant and user-friendly, including better handling of terminal dimensions and wrapped text. The changes add precision/width support for listopt, enable pax listing from stdin, and update vi to respect LINES/COLUMNS and wrap long lines on the screen.
Changes:
- Enhance
paxlist formatting by parsing format specifiers with flags, width, and precision, and add integration tests for%Mprecision (e.g.,%.1M) including stdin-based archives. - Add a binary-stdin helper for
paxtests to support feeding archives via stdin. - Update the
viterminal abstraction to honorLINESandCOLUMNSenvironment variables and implement line-wrapping logic in the screen buffer, with new unit tests around wrapping behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pax/options.rs |
Adds a FormatSpec parser and format_with_spec helper to support flags/width/precision for list format specifiers, enabling behaviors like %.1M while reusing existing handlers. |
pax/tests/options/mod.rs |
Introduces integration tests validating %M precision (%.1M) both from file-based archives and stdin-fed archives, ensuring the new formatting semantics behave as expected. |
pax/tests/common/mod.rs |
Adds run_pax_with_stdin_bytes helper to run pax with binary stdin, enabling the new stdin-based listopt tests. |
editors/vi/ui/terminal.rs |
Changes terminal size detection to first query ioctl, then override with LINES/COLUMNS if set and valid, and adds tests for environment-based overrides and invalid values. |
editors/vi/ui/screen.rs |
Documents and extends line expansion with a new expand_and_wrap_line helper and rewrites update_from_buffer to use wrapping, plus unit tests for wrapping with long lines, tabs, and empty lines. |
Add MAX_FORMAT_FIELD_SIZE constant (4096) to clamp width and precision values parsed from listopt format strings, preventing OOM attacks from malicious inputs like %9999999999999999p. Include test coverage for oversized format specifiers to verify clamping behavior.
Implements display window model with (top_line, top_line_offset) to ensure target lines remain visible when preceding lines wrap across multiple screen rows. The previous 1:1 buffer-to-screen assumption caused wrapped lines to push targets off-screen. Changes: - Add top_line_offset field tracking wrapped row offset within top_line - Add compute_wrapped_row_count() to calculate display row consumption - Refactor scroll_to_line() to compute display positions with wrapping - Update update_from_buffer() to render from (top_line, top_line_offset) - Add integration tests for wrapped visibility scenarios Preserves API compatibility while fixing the visibility invariant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.