Skip to content

Should diffWordsWithSpace treat consecutive new lines as a single "word"? #211

Closed

Description

@attaboy

The behavior of diffWordsWithSpace surprised me with its treatment of consecutive new lines as a single word.

For example:

Left:

A

B

Right:

A
B

Given the above, I would expect this diff:

[{ value: "A\n" }, { value: "\n", removed: true }, { value: "B\n" }]

Instead, I get:

[{ value: "A" }, { value: "\n\n", removed: true}, { value: "\n", added: true}, { value: "B\n" }]

Is this the expected behavior? I would love if it was configurable, because it's A) surprising and, B) if trying to display the diffs visually, it makes changes to new lines seem more complicated than they really are.

(I can see about opening a pull request if a change to this behavior is welcome.)

Activity

  1. Mingun commented on Mar 10, 2018

    @Mingun
    Contributor

    Just note that this is duplicate of #180.

  2. added a commit that references this issue on Mar 10, 2018
  3. added a commit that references this issue on Jan 10, 2019
  4. ExplodingCabbage commented on Dec 18, 2023

    @ExplodingCabbage
    Collaborator

    Fixed by #217.

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