Repository navigation
feat: render lf-diff through @pierre/diffs 1.7.1 - #7432
Merged
Merged
Conversation
@pierre/diffs 1.7 replaced the renderer's unifiedContentAST with row specs
(columns.unified). lf-diff now renders each row spec's content element, which
produces the same row markup as 1.6.1's content AST. Pierre also adds
contenteditable="false" to deletion, separator and no-newline rows.
- parsePatchFiles takes { throwOnError } in place of positional arguments.
- The file-type replacement names jsdiff explicitly and types its comparator
as jsdiff's option, since ParseDiffOptions now lists @pierre/patches' keys.
- The changed-word distance seam moves to utils/computeLineDiffRanges.js and
returns NO_RANGES.
- lf-deck's touch-swipe guard skipped any [contenteditable] target, so a
swipe begun on a diff row in a card stopped moving the card. It now skips
only editable content, as Leaf's control selectors already do.
Behaviour change: none intended on screen. The renderer bundle grows from
823 KB to 1071 KB, mostly @pierre/highlights' WASM (0.2.0 -> 0.5.2), and the
parser from 22 KB to 37 KB, which now carries @pierre/patches.
Closes #7430
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.
@pierre/diffs1.7 removed theunifiedContentASTthatlf-diffrendered from. Its renderer now returns row specs (columns.unified).lf-diffrenders each row spec'scontentelement instead, and gets the same rows 1.6.1 produced. A static render of a patch with changed words, a hunk separator and no-newline markers gives identical HTML on both versions except for two things. First, 1.7.1 still emits the icon sprite, whichlf-diffalready removes. Second, deletion, separator and no-newline rows now carrycontenteditable="false", which Pierre's editor uses.With 1.7.1 and the old
lf-diff, every diff failed withCannot read properties of undefined (reading 'type'). With this change,test_a_diff_marks_changed_words_only_where_the_line_mostly_stayed,test_a_diff_shows_native_file_metadata_without_empty_disclosures,test_the_widget_reads_the_diff_patch_tableand the rest of the diff tests intest_render_anchors.pypass. So do the diff export and lazy-loading tests, a selection oftest_render_diff_controls.py, andpnpm run check.The other API changes:
parsePatchFilesnow takes{ throwOnError: true }instead of positional arguments.ParseDiffOptionsnow lists@pierre/patches' keys, which have nocomparator. Pierre still passes options through to jsdiff, so the file-type replacement now namespreferredDiffLib: "jsdiff"and types its options as Pierre's plus jsdiff's. The existingcomparatoraugmentation inbrowser/types/native-modules.d.tscovers jsdiff's type.build/vendor.mjsmoves toutils/computeLineDiffRanges.jsand returnsNO_RANGES.lf-deck's touch-swipe guard ignored a press on any[contenteditable]element, so a swipe begun on a diff's deletion row inside a card would no longer move the card. The guard now skips only editable content ([contenteditable]:not([contenteditable=false])), which is howcontrol-selectors.jsalready treats it.test_a_swipe_begun_on_read_only_text_moves_the_cardfails without the change and passes with it.Bytes: the renderer bundle, which loads only once a diff draws its rows, grows from 823 KB to 1071 KB. Most of that is
@pierre/highlights' inlined WASM, which grows from 244 KB to 405 KB of base64 between 0.2.0 and 0.5.2. The parser grows from 22 KB to 37 KB, since it now bundles@pierre/patcheseven though Leaf parses with jsdiff.Something this change doesn't do: 1.7 adds
disableLineMatching, which "preserves the patch's change blocks and line order without similarity realignment". That may letjoinChangeRunsgo. It needs its own check against the rewrite case that function's comment describes.Closes #7430 — automated triage