microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.26k stars 29.3k forks source link

Support manual align in merge editor #165684

Open orgads opened 2 years ago

orgads commented 2 years ago

Sometimes the merge editor has wrong chunk alignment, and it would be useful to allow manual alignment.

Example for added/added lines conflict: image

If I'd choose "Accept combination", no matter for which side, the result would be wrong, because the right side is split to 2 chunks in the middle of the function.

What I'd like to do is to align the left side top line with the right side bottom line, and then accept both.

Beyond Compare 4 has 2 options to handle that. image

  1. Right-click on a line -> Align With (or left-click -> F7), then left-click on the target line in the other pane.
  2. Isolate - this is similar to Accept Combination in VS Code, but it is line-level. It isolates the chosen line to be one above its match in the other pane.
hediet commented 2 years ago

That's a good idea, thanks! The implementation could look like this:

Also, can you share your merge conflict for future reference? (Using the Copy Merge Editor State as JSON command)

orgads commented 1 year ago

@hediet I can't reproduce with a minimal example. Sent you the JSON of the original merge by mail.

swythan commented 1 year ago

Is this a reasonable place to request the same functionality in the 2-way diff as well?

hediet commented 1 year ago

@swythan Please create a different feature request. Also, please attach some example for which this feature would be really useful.