-
Notifications
You must be signed in to change notification settings - Fork 500
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
Word diff "ignores" newline and extra spaces #30
Comments
Sounds like something I needed a while ago, and luckily I sent a PR (#22 :). Try |
@papandreou don't |
Yeah, it's a little obscure. They use the same tokenization regexp, but https://github.com/kpdecker/jsdiff/blob/master/diff.js#L155-L156 The And uses it when deciding whether to consider two all whitespace fragments equal here: https://github.com/kpdecker/jsdiff/blob/master/diff.js#L137-L143 |
Oh thanks, I ended up switching to https://github.com/cubicdaiya/node-dtl, which lets me do my own tokenization without touching the code, but it's great to know this would also work! |
Could be nice adding this to the readme documentation.. |
Not sure if this is a feature or part of design, but whereas a line diff will treat a new line character (
\n
at least) as a potential difference, word diff will not. Indeed it's not a word, and I can see the inherent abstract consistency of this treatment. But it may come to mind providing control over what characters delimit words and what characters don't, for word diff. Anyway please don't break the API, the default should behave as it does now..Having said that, the problem is more severe than new line handling, e.g. any non-word delimiter such as a space character, is just swallowed during the word diff process, and does not show as a difference in the word diff result. I think this aspect should be reconsidered for improvement (while keeping default behavior as is).
The text was updated successfully, but these errors were encountered: