Skip to content

Applying a patch doesn't seem to work? #228

@nicferrier

Description

@nicferrier
[const jsdiff = require("diff");

let text = `# Markdown
This is some markdown.

Let's find the diffs
`;

let newText = `# Markdown
This is some markdown.

Let's find the diffs and prove it all works.
`;
let diff = jsdiff.structuredPatch("old", "new", text, newText);
let newDoc = jsdiff.applyPatch(text, diff);
console.log(newDoc);

and what I get back is:

/home/nicferrier/jswork/sqlparsing/node_modules/diff/lib/patch/apply.js:111
          delimiter = _hunk.linedelimiters[j];
                                          ^

TypeError: Cannot read property '0' of undefined
    at Object.applyPatch (/home/nicferrier/jswork/sqlparsing/node_modules/diff/lib/patch/apply.js:111:43)

I couldn't find a test that does this... but since structuredPatch is at the heart of all the patch routines that seems a bit odd.

Help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions