microsoft / vscode

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

Allow to compare 3 files #57687

Open sguillia opened 5 years ago

sguillia commented 5 years ago

VS Code allows to easily compare two files by choosing Select for compare and Compare with selected.

But we can only select two files.

diff3, kdiff3 and vimdiff do the job but I would prefer it integrated into VS Code.

This would be helpful!

Edit: would also be nice to be able to compare 4 files 😄 vimdiff and diffuse do

vscodebot[bot] commented 5 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

sguillia commented 5 years ago

I asked on Stack overflow beforehand if any extension already does the job.

My post got downvoted and voted for close.

The issue reporter suggests to ask questions on stack overflow with VS Code tag, and I didn't want to request a feature that an extension already provides.

Could anyone explain me what I did wrong??

chpxu commented 5 years ago

Eh nothing's wrong, it's more of Stack Overflow's community guidelines, they want you to be as relevant as possible (hence the tag problem the reporter said) and make sure you search as thoroughly as possible, and try to be as specific as possible (I understand what you meant), and if you want it integrated into VSCode as a Feature Request, then it's fine to post your idea here!

dbaeumer commented 5 years ago

Asking for 3 way diff support.

fokep commented 5 years ago

Diff on four (4) files would be great as well! It would REALLY help to justify the purchase ("investment towards productivity increase") of a 34" 3440x1440 monitor

Yes. n files. We might need two n of those monitors (for productivity).

vscodebot[bot] commented 4 years ago
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our [documentation](https://aka.ms/vscode-issue-lifecycle). Happy Coding!
vscodebot[bot] commented 4 years ago
:slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our [documentation](https://aka.ms/vscode-issue-lifecycle). Happy Coding!
vj68 commented 3 years ago

Any update on how this can be used? (diff for 3 files)

lucasmaffazioli commented 2 years ago

This would be very useful!

moseleyi commented 1 year ago

Diff for n files would be great. I have number of projects that use a base file that is nearly the same, however I would like to check which projects have custom code in it.

Gabrieloxe commented 1 year ago

Wondering if there is a possibility of getting this feature in 2023?

mooserson commented 1 year ago

Yet another n-differ hoping this makes it..

dtrts commented 11 months ago

Chiming in as an nth supporter wanting to diff n files :)

Paulo-Pinto commented 9 months ago

please

hediet commented 8 months ago

VS Code now has a three way diff editor.

srudolph-credera commented 8 months ago

For anyone (like me 🤦‍♂️) that was accidentally watching this ticket looking for 3-way merge version 1.69 (https://code.visualstudio.com/updates/v1_69#_3-way-merge-editor) introduced the feature and there's a menu item to show the base (two actually, one for top, one for center). See: https://github.com/microsoft/vscode/issues/155277.

martinvonz commented 8 months ago

@srudolph-credera, that seems to describe the 3-way merge editor (for merging a base and two sides, I would think).

@hediet, can you clarify how one opens the 3-way diff editor? Which version was it added in?

srudolph-credera commented 8 months ago

@srudolph-credera, that seems to describe the 3-way merge editor (for merging a base and two sides, I would think).

@hediet, can you clarify how one opens the 3-way diff editor? Which version was it added in?

Yes, indeed - I had mistakenly conflated them and wanted to help anyone else that had similarly done so. In figuring out what had been added to VS Code, I too could not find the 3-way diff support announcement/UI. I wonder if it got conflated with being able to show multiple 2-way diffs in the same pane, which was just released in preview: https://code.visualstudio.com/updates/v1_85#_multifile-diff-editor.

martinvonz commented 8 months ago

I wonder if it got conflated with being able to show multiple 2-way diffs in the same pane, which was just released in preview: https://code.visualstudio.com/updates/v1_85#_multifile-diff-editor.

Yeah, could be. Incidentally, the combination of that feature with 3-way diffs would be useful for us for giving the user a nice UI for splitting commits (https://github.com/martinvonz/jj/issues/1155). And ideally it can be started from the CLI. So that's what I'm really hoping for.

hediet commented 8 months ago

My mistake, I thought 3 way diff editor would refer to 3 way merge editor.

Can you describe the uses cases for a 3 way diff editor? How would they be diffed? A vs B and C vs B? or A vs B and B vs C, while aligning the two Bs?

martinvonz commented 8 months ago

I mentioned splitting commits above. You can use the same interface for something like git commit -i. I don't know that use cases others have in mind.

For splitting commits, we would want the content from the parent commit on the left, the content from the commit itself on the right, and the result (output) in the middle. We currently let users split commits by letting them edit the right pane in a 2-way diff instead. I think it would be useful to have the separate output in the middle, so you can compare that to the final state on the right.

hediet commented 6 months ago

The complicated part of a 3 file diff editor is to compute the line alignments: Given the diffs between A<->B and B<->C, each as { orig: Range, mod: Range }[] (Range having a start/end lineNumber/column), how do I compute the alignment-spacers (in form of { afterLineNumber: number, heightInLines: number }[]) for A, B and C, such that after inserting these spacers, unmodified lines are aligned (and modified lines are aligned heuristically)?

Morgy93 commented 2 months ago

PhpStorm can diff three files. Why can't we have such a feature?

code --diff <path1> <path2> [<path3>]

https://www.jetbrains.com/help/phpstorm/command-line-differences-viewer.html