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

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

Closed
attaboy opened this issue Jan 5, 2018 · 2 comments
Closed

Comments

@attaboy
Copy link

attaboy commented Jan 5, 2018

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.)

@Mingun
Copy link
Contributor

Mingun commented Mar 10, 2018

Just note that this is duplicate of #180.

Mingun added a commit to Mingun/jsdiff that referenced this issue Mar 10, 2018
Mingun added a commit to Mingun/jsdiff that referenced this issue Jan 10, 2019
@ExplodingCabbage
Copy link
Collaborator

Fixed by #217.

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

3 participants