Repository navigation
Wrap a diff's Markdown files by the page's language table, not a second list of extensions - #6969
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mdxMarkdown therefore got an.mdxdiff that scrolled sideways, and a page that took.mdaway still wrapped it. Meanwhilelf-diffcolours 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.overflowFornow askslangForPath(path) === "markdown"and keeps.txtas 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.mjsinstalls a language table that addsmdxand remapsmd. 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, andtests/browser/widgets/test_diffs.py::test_diff_wraps_prose_by_default_and_accepts_an_overflow_choice.