Skip to content

Wrap a diff's Markdown files by the page's language table, not a second list of extensions - #6969

Merged
leaf-agent merged 1 commit into
mainfrom
fix/diff-overflow-language
Nov 24, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/diff-overflow-language

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

A diff now decides which files wrap from the page's own language table, so a page whose packages add or remove a Markdown extension gets diffs that wrap the right files. Before this, overflowFor (packages/diff/widgets/overflow.js) kept its own regex, \.(?:md|markdown|txt)$. A page whose packages call .mdx Markdown therefore got an .mdx diff that scrolled sideways, and a page that took .md away still wrapped it. Meanwhile lf-diff colours each file by the composed table (langForPath), so the two could disagree about the same file.

The copy dates from a first-paint script (initial/lf-diff.js) that ran before the registry loaded. #4724 removed that script, and with it the copy's only reason. overflowFor now asks langForPath(path) === "markdown" and keeps .txt as plain text, since the table names no language for it. The registry's instructions for the diff ("Markdown and plain-text files wrap by default") already describe this behavior.

Test: tests/runtime/diff-overflow.test.mjs installs a language table that adds mdx and remaps md. It fails on the old regex (expected 'wrap', actual 'scroll') and passes with the fix. It replaces the old test, which only checked that the regex agreed with the shipped table.

Also ran: pnpm run test:runtime (1099 passed), pnpm run check:browser, pre-commit on the changed files, and tests/browser/widgets/test_diffs.py::test_diff_wraps_prose_by_default_and_accepts_an_overflow_choice.

…nd list of extensions

`overflowFor` decided which files a diff wraps with its own regex,
`\.(?:md|markdown|txt)$`. Its test explained the copy by a first-paint
script that couldn't read the registry, and that script is gone (#4724).
The page composes `$languages.paths` from its packages, which can add or
remove an extension, and `lf-diff` already colours each file by that table
through `langForPath`. So a page whose packages call `.mdx` Markdown got a
diff that scrolled the file sideways, and one that took `.md` away still
wrapped it.

`overflowFor` now asks `langForPath` whether a file is Markdown, keeping
`.txt` as plain text, which the table names no language for. The test
installs a table that adds `mdx` and remaps `md`; it fails on the regex and
passes now.
@leaf-agent
leaf-agent merged commit 1c1eaea into main Nov 24, 2026
7 checks passed
@leaf-agent
leaf-agent deleted the fix/diff-overflow-language branch November 24, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant