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

DiffChunks() with empty slices fails #10

Closed
chkno opened this Issue Nov 4, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@chkno

chkno commented Nov 4, 2016

DiffChunks([]string{}, []string{}) panics with "index out of range".

DiffChunks([]string{"foo"}, []string{}) emits an extra empty chunk[0] in the result.

0001-Failing-test-cases-for-DiffChunk-of-nil.patch.txt

@kylelemons

This comment has been minimized.

Owner

kylelemons commented Nov 8, 2016

Wow, yep there's a bug in there somewhere. I haven't immediately figured out where it is, though... the code was largely modeled on a research paper, and I made the mistake of using their totally-opaque names for everything, and have now forgotten most of how the implementation works. I'll try to get it fixed, but no promises on timeline.

The good news is that, for whatever reason, the algorithm seems to work fine for the usual cases that are called by the "pretty" package, so it's probably some degenerate case that's missing from the code. It could be as simple as hard-coding the "everything added" and "everything deleted" case, but I want to convince myself that the algorithm shouldn't be able to handle that first, before I do it.

@kylelemons kylelemons closed this in 7f5dacf Nov 9, 2016

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