Refined-github: Ability to expand all collapsed code in PR diffs

Created on 12 Jun 2019  路  18Comments  路  Source: sindresorhus/refined-github


Issuehunt badges

When reviewing PRs, sometimes it's useful to view the entire file with the diffs in context. To do this, one needs to click the expand diff button multiple times until the entire file is exposed.

I'd like to be able to alt-click one of the expand markers in collapsed code and have all code blocks expand at once (perhaps limited to the current file). A similar feature was recently added to VSCode, btw, so there's precedence for this.

There is already a feature to view the file at the commit associated to the diff being viewed, but then the full code is shown unmarked, without the diff indicating what changed.

Also, please note that this is about expanding/collapsing code within a diff, rather than folding entire files, which was a previous feature and was removed after it was implemented directly by GitHub (see #1486). What I'm talking about is this:

screenshot




IssueHunt Summary

tiramisu77 tiramisu77 has been rewarded.

Backers (Total: $60.00)

- #2434 Add expand-all-collapsed-code feature (#2151)

Tips

IssueHunt has been backed by the following sponsors. Become a sponsor


Rewarded on Issuehunt enhancement help wanted

Most helpful comment

And what you do is "Alt-Click" on this symbol? (That is, clicking when holding the Alt button?)

Does not work for me. Tested with Firefox and Chromium under Linux, and with Firefox (I believe) under Windows 10.
Would really like to have this working.

All 18 comments

@issuehunt has funded $50.00 to this issue.


Easiest solution: click all "expand" buttons until there are no more left, but this will cause multiple sequential loads and will look messy.

Ideal solution: load file from its "View file" link and then merge it with the current dom. This is probably a bit hard, especially on the split diff view.

Other solutions welcome

You can also clone the DOM node and replace it with the original one, then click on expand (from the original DOM tree) until there is no more left, and then put it back and remove the fake DOM node.

+1

I believe this is called unfold rather than expand in GH terms, because expand means expand/collapse of a file.

_Just wanted to add a comment to make the issue searchable with unfold tag. Thank you for the future implementation <3_

I believe this is called unfold rather than expand in GH terms

It doesn't look like it:

True, anyways, in their original blog post it was called unfold.. https://github.blog/2013-12-02-expanding-context-in-diffs/

Anyways, looking forward to seeing this feature :)

@adriantp has funded $10.00 to this issue.


Thanks, @tiramisu77 and @fregante! I just updated my extension to 19.9.19 and gave it a little test. It is indeed a little slow, as you noted in the PR comments, but considering that all you have to work with is UI elements, it works perfectly. Just alt-click one of the "expand" gutter buttons and all of the folded lines unfurl within a couple of seconds (depending on the size of the file and how many folded sections exist, obviously). Wonderful!

@sindresorhus has rewarded $54.00 to @tiramisu77. See it on IssueHunt

  • :moneybag: Total deposit: $60.00
  • :tada: Repository reward(0%): $0.00
  • :wrench: Service fee(10%): $6.00

This seems to be just the thing I have been looking for. But how does one use it?
(I tried to Alt-click on the "expand" buttons at the side of the file, but it only expands as it would if I had clicked the button normally - no "expand all" to be seen.
Can someone please explain?

I just tried it and it still works. Here's a demo

Try refreshing the page before clicking the button, maybe that's the bug

And what you do is "Alt-Click" on this symbol? (That is, clicking when holding the Alt button?)

Does not work for me. Tested with Firefox and Chromium under Linux, and with Firefox (I believe) under Windows 10.
Would really like to have this working.

Not working for me either on macOS (trying option + click).

Really would like to use this tool!

me too! this is a big thing for me that is missing when viewing PR' but cannot get this to work on mac OS :(

I'm on Firefox/macOS and can always make it work.

  1. Visit https://github.com/sindresorhus/refined-github/pull/2434/files
  2. Hold alt and click here:
    Screen Shot 2020-07-10 at 00 39 25

Click exclusively on the blue area in that screenshot, _not_ on the whole line, even if it highlights.

@fregante
Lucky you ;-)

I hold alt, and click in that blue box with the up-arrow and dots, and I get 20 more lines unfolding. Not all lines.
Firefox 68.10.0esr (64bit) on Windows 10.

Linux users that can't make it work can try remapping the alt key: https://github.com/sindresorhus/refined-github/issues/3436#issuecomment-670446085

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olso picture olso  路  3Comments

sompylasar picture sompylasar  路  3Comments

fregante picture fregante  路  3Comments

durka picture durka  路  3Comments

yakov116 picture yakov116  路  3Comments