Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch_toText, unified diff like output #9

Open
mariusk opened this issue Mar 9, 2018 · 0 comments
Open

patch_toText, unified diff like output #9

mariusk opened this issue Mar 9, 2018 · 0 comments

Comments

@mariusk
Copy link

mariusk commented Mar 9, 2018

The docs says this method should create something that looks like a unified diff. When I try it I just get "[object ...]" blah blah output. Looking at the actual source code for the method, it doesn't do much, it simply tries to output some of the objects in the diff. Here's the actual source code:

/**
 * Take a list of patches and return a textual representation.
 * @param {!Array.<!diff_match_patch.patch_obj>} patches Array of Patch objects.
 * @return {string} Text representation of patches.
 */
diff_match_patch.prototype.patch_toText = function(patches) {
  var text = [];
  for (var x = 0; x < patches.length; x++) {
    text[x] = patches[x];
  }
  return text.join('');
};

So patches[x] is a javascript object, and the text.join method just creates these faulty "object" strings. I can't find any code that does anything like the comments in the source code mentions. So I guess either we need some more code or the docs should be updated and mark this method as faulty.

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

No branches or pull requests

1 participant