Skip to content

diffWords treats \n at the end as significant whitespace #70

Description

@OleMchls

we have the following behavior:

coffee> diff = require 'diff'

# works as expected
coffee> diff.diffWords("hase igel fuchs", "hase igel fuchs")
[ { value: 'hase igel fuchs' } ]

# newline at righthand results in a change
coffee> diff.diffWords("hase igel fuchs", "hase igel fuchs\n")
[ { count: 5, value: 'hase igel fuchs' },
  { count: 1, added: true, removed: undefined, value: '\n' } ]

# newline at lefthand results in a change
coffee> diff.diffWords("hase igel fuchs\n", "hase igel fuchs")
[ { count: 5, value: 'hase igel fuchs' },
  { count: 1, added: undefined, removed: true, value: '\n' } ]

# newline in the middle words also as expected
coffee> diff.diffWords("hase igel fuchs", "hase igel\nfuchs")
[ { value: 'hase igel\nfuchs' } ]

when we read the documentation right, every whitespace should be ignored when using diffWords.

Any thoughts on that?

/cc @Partyschaum

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions