Fix vi to wrap long lines instead of truncating#555
Draft
Conversation
- Made expand_and_wrap_line() public in screen.rs - Rewrote refresh_screen() to use wrapped lines instead of truncation - Added calculate_cursor_screen_row() to properly position cursor with wrapped lines - Fixed cursor column calculation to account for wrapping within a line Co-authored-by: jgarzik <494411+jgarzik@users.noreply.github.com>
Added test_pty_vi_long_line_wrapping to verify that vi correctly wraps long lines across multiple display rows instead of truncating them. Co-authored-by: jgarzik <494411+jgarzik@users.noreply.github.com>
- Add guard against zero/very small terminal width to prevent division by zero - Replace magic string ' ' with LINE_NUMBER_WIDTH constant for consistency - Add named constant for test line length - Add early return when terminal is too narrow to display content Co-authored-by: jgarzik <494411+jgarzik@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix vi behavior for wrapping long lines
Fix vi to wrap long lines instead of truncating
Feb 8, 2026
jgarzik
requested changes
Feb 8, 2026
Contributor
jgarzik
left a comment
There was a problem hiding this comment.
CI fails. you must run cargo fmt
Co-authored-by: jgarzik <494411+jgarzik@users.noreply.github.com>
Contributor
Author
Fixed in 8f34320. Ran |
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.
Summary
Fixed vi to properly wrap long lines across multiple display rows instead of truncating them, as required by POSIX.
Changes Made
refresh_screen()usesexpand_line()which truncates instead of wrapsupdate_from_buffer()has correct wrapping logic but is unusedrefresh_screen()to use proper line wrappingTechnical Details
Modified Files:
editors/vi/ui/screen.rs: Madeexpand_and_wrap_line()publiceditors/vi/editor.rs: Rewroterefresh_screen()to properly wrap lines and position cursoreditors/tests/pty/mod.rs: Added integration test for line wrappingKey Implementation:
refresh_screen()now iterates through wrapped rows instead of assuming 1 buffer line = 1 screen rowcalculate_cursor_screen_row()to compute cursor position accounting for wrapped linesTesting
All existing tests pass (385 tests), new test added specifically for wrapping behavior.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.