Skip to content

Wrong result of JsDiff.diffLines when there is an empty line before a change #51

Description

@felicienfrancois
var oldStr = "Line1\n" + "\n" + "Line2\n";
var newStr = "Line1\n" + "\n" + "ChangedLine\n";
JsDiff.diffLines(oldStr, newStr);

outputs

[
  {
    "count": 1, // Should be 2
    "value": "Line1\r\n" // Should be "Line1\n\n"
  },
  {
    "count": 1,
    "added": true,
    "value": "ChangedLine\n"
  },
  {
    "count": 1,
    "removed": true,
    "value": "Line2\n"
  }
]

In fact it seems successive \n are replaced by \r and ignored in counts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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