Skip to content

fix(ci): force LF for diffview testdata fixtures on Windows#2932

Closed
johnjansen wants to merge 1 commit into
charmbracelet:mainfrom
johnjansen:fix/diffview-testdata-line-endings
Closed

fix(ci): force LF for diffview testdata fixtures on Windows#2932
johnjansen wants to merge 1 commit into
charmbracelet:mainfrom
johnjansen:fix/diffview-testdata-line-endings

Conversation

@johnjansen
Copy link
Copy Markdown
Contributor

Problem

On Windows CI, TestDiffViewWidth/Split/WidthOf082 fails with a golden
mismatch: the closing } renders red (#d20f39, the catppuccin-latte
keyword color) instead of grey (#4c4f69, the text color). Example:
https://github.com/charmbracelet/crush/actions/runs/25949037144/job/76283113121

Root cause

The test embeds Go-source fixtures via go:embed:

//go:embed testdata/TestMultipleHunks.before
var TestMultipleHunksBefore string

These .before/.after files have no entry in .gitattributes, so on
Windows checkouts with the default core.autocrlf=true they get
converted to CRLF on disk. Chroma's Go lexer then sees }\r\n at EOF
and tokenizes the trailing brace inconsistently — at most widths the
renderer still picks the text color, but at width 82 the layout boundary
exposes a token that's been classified as a keyword.

Linux and macOS check out with LF, so the issue is invisible there. The
golden files are already protected via *.golden ... -text, but the
source fixtures that feed chroma are not.

Fix

Pin the embedded fixtures to LF in .gitattributes:

internal/ui/diffview/testdata/*.before text eol=lf
internal/ui/diffview/testdata/*.after  text eol=lf

This forces git to keep these files LF in the working tree on all
platforms, matching what's stored in the repo and what macOS / Linux
contributors already see.

Test plan

  • go test ./internal/ui/diffview/... passes locally on macOS
    (baseline — was already passing).
  • git check-attr eol internal/ui/diffview/testdata/*.before
    reports eol: lf after the change.
  • CI on Windows passes — to be verified by this PR's checks.

No code change, no behavior change on Linux/macOS, no golden
regeneration needed.

@johnjansen
Copy link
Copy Markdown
Contributor Author

Closing as superseded / stale relative to v0.70.0.

@johnjansen johnjansen closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants