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

Improvement: diff multiple blocks #26

Open
hcgraf opened this issue Feb 7, 2017 · 3 comments
Open

Improvement: diff multiple blocks #26

hcgraf opened this issue Feb 7, 2017 · 3 comments

Comments

@hcgraf
Copy link
Contributor

hcgraf commented Feb 7, 2017

Hi,

I have an idea for an improvement, which might hopefully be quite easy to implement (however, I didn't have time to look at the actual implementation myself, yet).

It would be great to be able to diff more than two blocks of code. VIM is actually capable of up to 8(!) buffers in diff mode (see :help E96).

So maybe keep the normal :Linediff as usual, but add some lower level commands like e.g. :LinediffAdd to add a new block (from 1-8), and then :LinediffDo or :LinediffShow to create the diff tab.

At the moment, I'm doing this procedure manually, but especially Linediff's feature of copying back the changes would be really great :)

Regards
Hagen

@AndrewRadev
Copy link
Owner

It seems like a reasonable idea to me, and the interface you describe sounds sensible. There's a technical difficulty in that the two differ objects have a connection between them -- updating the lines in one of them needs to update the other, because it might have to shift a bit. I guess if there are multiple ones, there would need to be a list of them that need to be updated in order. I'm sure I have that already in my writable_search plugin, but the mechanics there are a bit different. I'll see what I can do.

@hcgraf
Copy link
Contributor Author

hcgraf commented Feb 8, 2017

I had a quick look at the code and I think it would be quite possible.
You already have the differ objects in an object-oriented manner, so you could just have a list instead of two instances.

I think the order of updating the differ instances doesn't matter, as long as only one of them is saved at the same time. The same logic applies, if the changed differ is in the same file above, shift by the offset.
If multiple differ-buffers are saved at the same time, you just need to follow the order copy-to-original-buffer, update-other-differs, copy-to-original-buffer, update-other-buffers, …
Also the same as now.

I might have time in the next days / weeks to try and come up with a patch, but it's not sure yet.

@AndrewRadev
Copy link
Owner

It would certainly be possible, I'm sure of that, the question is just how hard it would be to get it done, change the objects appropriately, clean up any unexpected bugs. I think it's a good idea to finally introduce some tests to this project as well, I'm getting annoyed of trying things out manually.

If you have the time and energy to propose a PR, it would certainly be appreciated. If not, I'll get around to it at some point myself. I'll probably start by writing some tests for the existing features, and only then the feature, so it might be some time until I have a working version.

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

2 participants