Skip to content

vt_screen scrubbers shift indentation on unbordered CLI lines #143

In review

Description

@tony

Summary

When serialize_vt_snapshot() or vt_screen() scrubs a token near the end of an unbordered 1D CLI row, _absorb_2d_slack() falls back to scanning leftward (_scan_gap(rep_start - 1, -1)) whenever no >=2-space gap sits to the right of the replacement. On indented lines this injects or deletes spaces inside leading indentation to match the unscrubbed line width, and on padded CLI rows with a trailing duration (1.2s vs 10.2s) it produces different inter-column spacing for identical scrubbed output.

Reproduction

  1. Run serialize_vt_snapshot() with scrubbers on an indented CLI line and on two durations of different byte widths:

    $ uv run --no-sync python -c '
    from libvt import Terminal
    from libvt.testing import serialize_vt_snapshot, vt_screen
    
    t_indent = Terminal(rows=1, cols=80)
    t_indent.feed(b"    Full debug log: /tmp/pytest-of-runner/pytest-12/sync.log")
    print(serialize_vt_snapshot(vt_screen(t_indent, scrubbers=[(r"/tmp/\S+", "<LOG>")])))
    
    for dur in (b"1.2s", b"10.2s"):
        t_row = Terminal(rows=1, cols=60)
        t_row.feed(b"  - hung-repo  -> /work/hung-repo  (" + dur + b" elapsed)")
        print(serialize_vt_snapshot(vt_screen(t_row, scrubbers=[(r"\d+\.\ds", "<DUR>")])))
    '

Expected

Unbordered rows with no >=2-space alignment gap to the right of the scrubbed token preserve their leading indentation (4 spaces, cursor=(0,25)) and produce identical snapshots across 1.2s and 10.2s (2 spaces before (<DUR> elapsed), cursor=(0,50)).

Actual

_absorb_2d_slack() scans leftward across the row, inflating 4 leading spaces to 39 spaces (cursor=(0,60)) and collapsing the 2-space gap before (1.2s elapsed) to 1 space (cursor=(0,49)) while leaving (10.2s elapsed) at 2 spaces (cursor=(0,50)):

size=80x1 cursor=(0,60,vis=True) alt=False modes=[]
┌────────────────────────────────────────────────────────────────────────────────┐
│                                       Full debug log: <LOG>                    │
└────────────────────────────────────────────────────────────────────────────────┘
size=60x1 cursor=(0,49,vis=True) alt=False modes=[]
┌────────────────────────────────────────────────────────────┐
│  - hung-repo  -> /work/hung-repo (<DUR> elapsed)           │
└────────────────────────────────────────────────────────────┘
size=60x1 cursor=(0,50,vis=True) alt=False modes=[]
┌────────────────────────────────────────────────────────────┐
│  - hung-repo  -> /work/hung-repo  (<DUR> elapsed)          │
└────────────────────────────────────────────────────────────┘

Environment

Versions
  • libvt: 0.0.1a5 (587227c)
  • Python: 3.15.1
  • OS: Linux (x86_64)

References

Activity

  1. added
    bug
    p1
    on Dec 2, 2026
  2. tony commented on Dec 3, 2026

    @tony
    MemberAuthor

    In the seven-column fixture │pid=9│, the divider kept its column and the yellow span stayed at columns 5–6 after scrubbing. Callers can include padding in the match for fixed-width fields. PR #149 carries the serializer and all 23 regression tests from the overlapping scrubber branch. PR #144 closed after those matched the published replacement. PR #149 · PR #144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugp1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions