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

[Feature] Smart merge #513

Open
mudejar opened this issue Jun 21, 2024 · 1 comment
Open

[Feature] Smart merge #513

mudejar opened this issue Jun 21, 2024 · 1 comment

Comments

@mudejar
Copy link

mudejar commented Jun 21, 2024

First off, thank you for this useful plugin.

VScode has a pretty neat feature that allows a same line conflict to be resolved very quickly and efficiently.

From here: https://code.visualstudio.com/docs/sourcecontrol/overview#_resolving-conflicts

For some conflicts, the merge editor shows an Accept Combination button. Accepting the combination resolves the current conflict by smartly merging both changes. This is especially useful for changes in the same line that don't touch the same characters.

Would it be feasible to add something like this to this diffview plugin?

@tmillr
Copy link

tmillr commented Aug 13, 2024

The hard part is reconciling intraline differences made by ours and theirs, and handling all the edge cases (e.g. ignoring whitespace, more than 2 changes total to a line, etc.).

Here's an idea/rough starting-point (just quickly whipped this up on my own so it needs to be cleaned up and it's probably buggy atm):

https://gist.github.com/tmillr/418f91c9e5e251730d47905ca9fd99ba

I love little challenges like this, but the actual algorithm used by vscode may already be public/open source? If so, it'd probably be straightforward and easy to port over to lua/neovim. I also had the idea of utilizing regular diff (e.g. vim.diff) and just splitting the respective lines (e.g. on every character) beforehand, but I'm not sure if/how that'd work if at all (again you'd probably have to handle whitespace and empty lines specially/intelligently).

But I do agree and think this would be a cool feature (which is why I've tried to implement it on my own already).

Edit: https://github.com/microsoft/vscode/tree/391d289c8519678454e1e04958f8785d827561aa/src/vs/workbench/contrib/mergeEditor/browser

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