Skip to content

Bug with newlines in getStructuredPatch with { newlineIsToken: true } #235

Description

@Dzenly

Hi!

newlineIsToken is not documented for getStructuredPatch, so may be we need throw some exception for such case.

oldFile:

a


b

newFile:

a

c
d


b

I.e. added c\nd\n\n

The result is:

[
  {
    "oldStart": 3,
    "oldLines": 0,
    "newStart": 3,
    "newLines": 1,
    "lines": [
      "+c"
    ]
  },
  {
    "oldStart": 4,
    "oldLines": 0,
    "newStart": 5,
    "newLines": 3,
    "lines": [
      "+d",
      "+",
      "+"
    ]
  }
]

So there is an error either in the first chunk, because newline is lost,
or in the second chunk, because there is wrong redundant newline.

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