Skip to content

vi, pax fixes#552

Merged
jgarzik merged 4 commits intomainfrom
updates
Jan 26, 2026
Merged

vi, pax fixes#552
jgarzik merged 4 commits intomainfrom
updates

Conversation

@jgarzik
Copy link
Contributor

@jgarzik jgarzik commented Jan 26, 2026

No description provided.

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
@jgarzik jgarzik requested a review from Copilot January 26, 2026 22:29
@jgarzik jgarzik self-assigned this Jan 26, 2026
@jgarzik jgarzik added the bug Something isn't working label Jan 26, 2026
@jgarzik jgarzik changed the title Updates vi, pax fixes Jan 26, 2026
Copy link

Copilot AI left a 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 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 pax list formatting by parsing format specifiers with flags, width, and precision, and add integration tests for %M precision (e.g., %.1M) including stdin-based archives.
  • Add a binary-stdin helper for pax tests to support feeding archives via stdin.
  • Update the vi terminal abstraction to honor LINES and COLUMNS environment 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.
@jgarzik jgarzik merged commit 3c882ba into main Jan 26, 2026
6 checks passed
@jgarzik jgarzik deleted the updates branch January 26, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant