Improve integration with `react-diff-view` and investigate if `unidiff` can be entirely obsoleted and deprecated. (Originally: "Is there a way to remove the `======` separator that appears at the top of diffs?")

Open
#624 6 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
tooling

Research direction

Start at src/patch/create.ts around line 266 and reproduce the diff output consumed by react-diff-view. Compare the generated output with the git diff and unidiff formats described in the issue and determine whether the separator can be avoided; done means react-diff-view no longer requires caller-side stripping and the status of unidiff deprecation is documented.

Written by the indexing model from the issue text.

Description

I'm using jsdiff with react-diff-view and am finding myself having to remove the =================================================================== line that appears at the top of the output diff, like so:

    if (lines.length > 0 && lines[0].startsWith("======")) {
        // Find the first --- line and start from there
        const headerStart = lines.findIndex((line) => line.startsWith("---"));
        if (headerStart >= 0) {
            return lines.slice(headerStart).join("\n");
        }
    }

The reason appears to be the same as is described in this issue, in that react-diff-view expects diffs to be in either git diff or unidiff format.

Can you please help me understand why it gets included in jsdiff output, and whether there's a way to prevent it? I'd love to avoid having to strip it myself.

Thanks!

Dominant language
JavaScript
Stars
9.2k
Forks
555
Avg merge
1d 9h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kpdecker/jsdiff

All issues in kpdecker/jsdiff

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.