`Screen::parse` refuses text snapshots that 0.11.1 and 0.11.6 wrote

Open
#643 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
testing-qa

Research direction

Start with screen/parse.rs around parse_header and lay_out_row, then compare the cursor handling in serde_impl.rs and the JSON row reader. Add both reported snapshots to tests/compat/ and verify they parse; done means the pending-wrap and stranded-wide-character files are accepted, including the JSON-to-text round trip.

Written by the indexing model from the issue text.

Description

bug

What happens. Two shapes that earlier releases wrote no longer parse. The files below were written by the published crates, with the probe's lockfile resolving termlens 0.11.1 and 0.11.6 from crates.io:

  1. The pending-wrap cursor (0.11.1). After a write filled the last column, releases up to 0.11.1 wrote the cursor one past it. printf '\r\nabcdef' on 6x2 produced size: 6x2 cursor: 1,6.
    Reading that file with 0.11.7: line 1: cursor 1,6 is outside the 6x2 grid, and termlens render exits 2.
  2. A wide character stranded by a narrowing resize (0.11.6). On vt100 0.16, printf 'abcd東xy\r\nABC東' on 8x3 followed by resize(5, 3) left 東 wide in the last column, with no continuation cell. That is the truncation case DESIGN §3 describes.
    Reading the text save with 0.11.7: line 2: the row is wider than the 5 columns the header declares.

The JSON reader accepts both shapes: #375 handled the cursor, and check_row the stranded character. So the JSON twin of the second file reads, but its own with_styles() output then fails to parse again (JSON → text → parse).

The claim. docs/STABILITY.md: "A file written by any release from 0.10.1 on parses in every later release and renders back byte for byte."

Cause. screen/parse.rs:160 bounds the cursor at cols - 1. parse.rs:249 refuses a row whose wide character's second column falls one past the edge.

Fix.

  • In parse_header, clamp c == cols onto cols - 1, as serde_impl.rs:162 does.
  • In lay_out_row, accept a wide character whose second column is exactly one past the edge, marked wide with no continuation cell, as the JSON reader allows.

Done when both files read, with a pending-wrap file and a stranded-wide-character file added to tests/compat/. The corpus missed both shapes.

Dominant language
Rust
Stars
28
Forks
24
Avg merge
11h 23m
Merged PRs (30d)
42

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vyncint/termlens

All issues in vyncint/termlens

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.