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

Improve identification of separate diffs when only indentation is different #109

Open
michael-crawford opened this issue May 23, 2017 · 1 comment

Comments

@michael-crawford
Copy link

michael-crawford commented May 23, 2017

This is a minor quibble, but it's impacting me due to some changes I'm having to make to a large number of files, and I otherwise think this plugin is excellent, so I thought I'd suggest an improvement...

I'm attempting to make a mostly similar block of code optional via a command line parameter in a bunch of files. I want to have a file which has been modified to the left, so I can then diff repeatedly with unmodified files on the right, moving over the change which is mostly the if statement and the increase in indent level, but avoiding an overwrite where the two files do actually differ.

The diff identification algorithm is finding a few lines further down than I'd like, that happen to match, skipping over multiple line breaks which would normally trigger a separate diff. This prevents use of the copy-to-right button to move the much larger sections of code which are identical except for the indent, as they always seem to have one line which has a difference. So, I have to manually cut-and-paste between the two panes to avoid overwriting the few lines which are different in each file.

What I'd like to see, is something more sophisticated than the current "ignore whitespace" checkbox when it comes to detection of when code which is different only in the indent, used to:

  • be more sophisticated in synching left/right scrolling during a diff, if the code only differs in the indent level for a large section of contiguous lines, with a single begin if, end if type statement above and below, treat that as a match for scroll synchronization purposes, but still show it as a diff which can be moved via copy-right/left buttons.
  • detect this situation, and instead of attempting to find one line which happens to match to separate one diff from the next, look for the largest block which matches other than a difference in indent, and then use the blank lines which correlate in each to split up into separate diffs. This would allow me to move over the large blocks of code which differ only in indent level via copy-right, while avoiding a copy of the lines which differ both in indent and in content.

I uploaded a picture which shows the problem, which hopefully will help you visualize.
http://tinypic.com/r/2dwfdj6/9

@mupchrch
Copy link
Owner

This package uses a diff algorithm. What you are suggesting sounds like it might be fixed by switching the algorithm to a more robust one. My hope is this issue would go away for you once #114 has been fully accomplished.

Is that a fair assumption?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants