Skip to content

fix(changes): modified-file diffs render incorrectly in Windows Terminal #1491

Description

@santiagosuarezz

Before submitting

  • I searched open and closed issues and did not find a report of this problem.
  • I reviewed this report and removed credentials, tokens, private paths, hostnames, and other sensitive data.

Problem

The Gentle Changes viewer renders modified (M) files with corrupted columns and vertical separators in Windows Terminal. Added (A) files render normally. This makes the diff difficult to read and inspect.

Steps to reproduce

  1. Use Windows Terminal 1.24.11911.0 with PowerShell.

  2. Start Pi 0.87.1 with npm:gentle-pi@3.5.1 enabled in a Git repository.

  3. Create or edit an existing text file so that it is modified (M) and contains tab-indented or mixed-content lines. For a deterministic case, modify an existing file containing lines such as:

    	const before = 1;
    
  4. Press Alt+G to open Gentle Changes.

  5. Expand the worktree and select the modified file.

The issue is specific to the modified-file diff path; newly added (A) files do not show the same corruption.

Expected behavior

The selected diff should render as a readable, width-constrained two-pane view. Frame borders, separators, indentation, and added/removed lines should remain aligned with the terminal columns.

Actual behavior

The modified-file diff shows displaced text, broken alignment, and vertical frame artifacts across the pane. Lines containing tabs/control characters can cause terminal tab expansion to disagree with the TUI width calculation. The same view is readable for added files.

Environment

  • gentle-pi: 3.5.1
  • Pi: 0.87.1
  • Operating system: Windows 11
  • Terminal: Windows Terminal 1.24.11911.0
  • Shell: PowerShell

Relevant logs or error output

No runtime exception or error is shown. This is a visual rendering/layout failure. A screenshot demonstrating the issue is available in the original reproduction context.

Suspected cause

lib/shell-changes-view.ts passes diff lines containing tabs/control characters into width-constrained rendering. Normalizing those characters before visibleWidth/truncateToWidth avoids the mismatch.

Proposed fix

Sanitize each diff line and expand tabs before classification/rendering, with regression coverage for tabbed CRLF modified diffs. A local validation run passes 32 focused shell-changes-view tests.

No activity

Activity on this issue will appear here.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions