Skip to content

feat(merge): add conflict_choose_side action to replace merged buffer with one whole side#276

Merged
dlyongemallo merged 1 commit into
mainfrom
263-ours_theirs
Jul 1, 2026
Merged

feat(merge): add conflict_choose_side action to replace merged buffer with one whole side#276
dlyongemallo merged 1 commit into
mainfrom
263-ours_theirs

Conversation

@dlyongemallo

Copy link
Copy Markdown
Owner

Bound to <leader>cso/<leader>cst/<leader>csb.

Based on this comment: #263 (comment)

…er with one whole side

Bound to `<leader>cso`/`<leader>cst`/`<leader>csb`.
@dlyongemallo dlyongemallo merged commit a16d847 into main Jul 1, 2026
8 checks passed
@dlyongemallo dlyongemallo deleted the 263-ours_theirs branch July 1, 2026 12:26
@pksunkara

Copy link
Copy Markdown

What is the difference between <leader>cO and <leader>cso?

I think you might have misunderstood that <leader>cO keymap doesn't exist. They replace the whole file instead of just those conflicts.

@dlyongemallo

Copy link
Copy Markdown
Owner Author

I don't understand your comment. They very clearly do different things, conceptually speaking.

<leader>cO calls conflict_choose_all("ours"), which parses the conflict markers in the MERGED buffer and replaces every conflict region with the OURS content. Text outside the marker blocks is unchanged, and if there are no marker blocks, it does nothing.

<loader>cso (just added) calls the new conflict_choose_side("ours"), which has nothing to do with the conflict markers and just overwrite the entire MERGED buffer with OURS.

Say you have a diff conflict which is partially automerged, and partially requires intervention. Let's say region A is changed in OURS, region B is changed in THEIRS, and region C has a conflict.

<leader>cO changes region C to OURS. Note that it does not change region B, because there was no conflict there.

<leader>cso changes both regions B and C to OURS.

Note that <leader>cO and 2do can diverge as well, if a conflict region can be partially resolved. Let's say in region C, OURS and THEIRS modify the same line (conflict), but THEIRS modifies a following line (without conflict). <leader>cO would take the OURS version of the conflicted line but leave the unconflicted line alone, whereas 2do (depending on diffopt) may fuse the marker block and the subsequent change into one hunk, in which case 2do will replace the whole span with OURS, losing the change from THEIRS for the following line.

There are 3 tiers of mechanisms here (maybe you can think of them as levels of granularity) for getting content into the MERGED buffer during conflict resolution: (1) based on conflict markers (conflict_choose, conflict_choose_all), (2) based on diff hunks (:diffget, {1,2,3}do), and (3) whole buffer.

@pksunkara

Copy link
Copy Markdown

Let's say region A is changed in OURS, region B is changed in THEIRS, and region C has a conflict.

cO changes region C to OURS. Note that it does not change region B, because there was no conflict there.

cso changes both regions B and C to OURS.

I guess so, but I got confused because I didn't ask for this and I thought this was supposed to fix something. Nevermind then.

Thanks for the explanation.

@dlyongemallo

Copy link
Copy Markdown
Owner Author

I didn't ask for this and I thought this was supposed to fix something.

In #263, you wrote: "And it should also work when one of the side has deleted the file."

This is why I asked whether what you were requesting is to be able to choose an entire side's contents independently of any marker block. That ability is a pre-requisite to being able to restore (the whole buffer of) a deleted file.

@pksunkara

Copy link
Copy Markdown

That makes sense. I did't think of it. Thanks, appreciate this.

@dlyongemallo

Copy link
Copy Markdown
Owner Author

I've filed #282 as the follow-up issue to handle deleted files.

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

Successfully merging this pull request may close these issues.

2 participants