vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Suggestion: collapse unchanged regions in diff

Open factormystic opened this issue 8 years ago • 21 comments

When viewing a diff (2 pane or inline) it would be useful to collapse the unchanged lines. This helps focus in on just the changes, especially when the changes are few an spread out.

factormystic avatar Feb 29 '16 19:02 factormystic

any update on this one? Very rough transition from text-based git to VSCode because of this feature lacking.

bkarlson avatar Jul 06 '18 13:07 bkarlson

bump...

bkarlson avatar Oct 19 '18 04:10 bkarlson

This would be very nice to see. Right now, with big files I'm opening Vim (with fugitive plugin) in the terminal to clean up the diffs

benlindsay avatar Sep 13 '19 16:09 benlindsay

This is something I can't live without, the collapsing along with the inline Stage/Discard buttons makes it so much easier to keep commits tidy:

image

This screenshot is from GitX — still by far my favorite Git UI. I have tried literally all the extensions in VS Code, but none comes even close. I think this is something the core editor has to provide.

rijk avatar Apr 11 '20 12:04 rijk

no update on this issue? any one knows any extension?

this issue is open since 2016

aghArdeshir avatar Apr 15 '20 13:04 aghArdeshir

VS Code could really stand to make some huge improvements by looking at Atom's git support -- viewing diffs, walking through changes & staging them, as well as undo/reset ... it really is quite a bummer that these features are lacking.

ryran avatar May 13 '20 07:05 ryran

Yeah. To hide unchanged context is a very common feature for all diff editor and I think the MS developers also need this feature for each commit. I wonder why they abandoned the implementation for such a long time.

VSCode has built-in collapse/expand feature for code editor. A different algorithm would make the deal it seems.

KayLeung avatar Jul 04 '20 10:07 KayLeung

four year..... the function is still missing.

jianboy avatar Aug 19 '20 23:08 jianboy

This is, by far, my most wanted feature. It is standard in many other tools, specially when doing source control diffs.

I'd appreciate some comment from the team as to why is not being considered. Is it too hard to implement?

cristian3d avatar Sep 30 '20 03:09 cristian3d

The only reason I'm still using GitHub Desktop is because of this missing functionality. I'm often working on large files of C/C++ with 1000s of lines of code and long scrolls are just killing me.

Please make sure that the "selecting ranges to Stage" feature won't break!

andronat avatar Nov 06 '20 03:11 andronat

related to #87944

ToMakeSense avatar Dec 14 '20 04:12 ToMakeSense

This is one of the main things Magit gives me and Magit is the only reason I use Emacs anymore, please add this feature.

thesoftwarephilosopher avatar Mar 07 '21 00:03 thesoftwarephilosopher

i know i'm not supposed to comment just to 👍 but here i am commenting simply to 👍 anyone know of a plugin to do this instead?

jakedowns avatar Mar 30 '21 23:03 jakedowns

@jakedowns Try using the "vscode-diff" extension. It doesn't solve the problem in this issue. However it generates and opens the output of git diff in VS Code.

Do note that if you're on Windows, you need to modify the JS file of the extension to fix the problem described in huytd/vscode-diff#1

And if you want a nicer view, you can add the "Diff Viewer" extension. You'll have to make the same change above (to "vscode-diff" regardless of environment) to change to the diff extension. Then right-click the editor tab and click Reopen Editor With... to choose Diff Editor.

ADTC avatar Aug 15 '21 22:08 ADTC

It is a shame that git diff provides better overview of changes than VS Code. 👎🏻

saxicek avatar Apr 09 '22 03:04 saxicek

Maybe this is waiting for community contributions. Is this the right file?

https://github.com/microsoft/vscode/blob/main/src/vs/editor/browser/widget/diffEditorWidget.ts

HebaruSan avatar Aug 06 '22 15:08 HebaruSan

It is a shame that git diff provides better overview of changes than VS Code. 👎🏻

Not just git diff. Github itself, Bitbucket, Beyond Compare, pretty much all code diff tools do this.

archon810 avatar Sep 02 '22 16:09 archon810

I left VS Code for WebStorm a few years ago. I thought I might come back, but I keep bumping into things like this.

ThomasGHenry avatar Sep 05 '22 20:09 ThomasGHenry

Hi @archon810 nice bumping in to you 😁

Agree, for now I just use the "jump to next change" button to work around this, but the current diff viewer makes for a cluttered experience.

jordyvandomselaar avatar Sep 06 '22 13:09 jordyvandomselaar

Cluttered and a little stressful, because I never feel 100% sure I've seen everything.

rijk avatar Sep 06 '22 13:09 rijk

this would definitely be a much needed feature

Something similar to Intellij diff as shown bellow:

FarisHijazi avatar Sep 21 '22 18:09 FarisHijazi

Please..? I've tried to get used to this, but with collapsed regions the UX is just much better. I keep going back to Sourcetree just because of this.

ivnsch avatar Oct 11 '22 07:10 ivnsch

The problem is that the folding does not even work inside a diff file. In my case I would like to get a screenshot for a small diff, the diffs are in the same file, but in different far locations, so it's not possible to fold irrelevant code, or to have some option to show only the diffs as in other tools.

vsambor avatar Nov 15 '22 15:11 vsambor

This is currently the only reason why I got some trouble to move from Atom to VS Code :( It would be awesome to have this feature implemented !

thomashbrnrd avatar Dec 26 '22 09:12 thomashbrnrd

@thomashbrnrd I just use another tool for diff. VSCode is better than Atom so this one thing shouldn't stop you.

(Also I believe Atom is retired.)

ADTC avatar Dec 26 '22 10:12 ADTC

@ADTC Yes Atom is retired, but Atom was really better than VS Code on the versioning / git side. This feature that we request here was implemented long time ago in Atom ...

May I ask what tool you are using for the git diff and stage / commit only some parts of a file ?

thomashbrnrd avatar Dec 26 '22 10:12 thomashbrnrd

@thomashbrnrd I prefer to use Git in terminal command line (external) and visually in another tool. In VS Code I use some Git related extensions but only to get information about the current history.

If you're on Windows, you can try Git Extensions. It's very good and can do line by line staging. It's also possible to use it on Mac with some strange emulation but I didn't want that so I switched to Fork on my new Mac.

ADTC avatar Dec 26 '22 10:12 ADTC

@thomashbrnrd If you're comfortable with text mode tools, you could use interactive add (git add -i).

If you prefer GUI and you're fine with the tool not being exceptionally pretty, I'd recommend the official git-gui, which comes out of the box with Git on some platforms (on many Linux distros you'd have to manually install the corresponding package, typically, git-gui). It's what I use and it works reasonably well.

It really does suck that it has taken so long for VSCode to still have no support for hiding/collapsing unchanged diff regions. Evidently, garbage like "custom Explorer autoreveal logic", "hide Activity bar and Panel badges" or "new font setting for OpenType fonts" is more essential to the development workflow for some; since this issue was opened almost 7 years ago there have been tens of releases with hundreds of superfluous insignificant features like those. :disappointed:

antichris avatar Dec 26 '22 13:12 antichris

I use Winmerge to compare. It can show only differences (set context to 0). Beyond Compare should also have this essential feature.

Edit: Notepad++ also has this feature with comparePlus plugin

https://github.com/pnedev/comparePlus

jeesusonherraturku avatar Jan 13 '23 15:01 jeesusonherraturku

How is it possible that this hasn't been done in 6 years! Much needed feature to be competitive with, e.g., PyCharm. Please have a go at implementing it :pray: Thanks!

mtazzari avatar Jan 27 '23 11:01 mtazzari