-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Ignore Whitespace in DiffMatchPatch #133
Comments
@deepanshukhanna this library creates a diff patch to get from one version of a document to another; ignoring whitespace or formatting would break that output as the diffs it produces would no longer be able to be used to move between the two versions. you might want to look into treating |
@dmsnell We are using diff-match-patch as a library, and we have written some extensions to use it for our requirements. Motivation behind this ask: Most of the editors and git provides this configuration to ignore whitespaces between versions of code. We are relying on diff-match-patch to get diffs between version of codes. Without an option to ignore whitespaces changes, we are getting diffs with whitespaces changes as well. While doing some critical computations on newly introduces changes, it doesn't make sense to do it on old code that is being parsed just because of some whitespace introduction.
Removing whitespaces from start and end of line before changing it to unicodes might be helpful and give expected diffs here while ignoring whitespaces. But yes, I believe same unicodes are converted back to line before returning diffs so those removed spaces should be added back for those lines somehow. |
my point is that in some languages this gives a diff that hides relevant semantic changes in the code. if __DEBUG__:
print_sys_stats()
print_all_the_secrets() to if __DEBUG__:
print_sys_stats()
print_all_the_secrets() is a fairly massive change but hidden if we assume whitespace is irrelevant. to restate, I don't think or you could pre-process your files and remove the whitespace, then create a diff. either way I think looking to this library to ignore whitespace might be an uphill battle compared to addressing it at your application level.
something may be lost in the comment here because I'm not understanding what you are talking about. note that you can get structural diff output which contains a list of diffing operations and examine that to look for those operations which only add or remove whitespace.
|
Currently there is no way we can ignore those diff if there is only a whitespace or formatting done on the code block. If we can add some feature which can be enabled and then we can ignore those changes which were found due to whitespace only.
The text was updated successfully, but these errors were encountered: