Refined-github: Apply auto-linking after unfolding diffs

Created on 28 May 2019  ·  7Comments  ·  Source: sindresorhus/refined-github

This is a follow-up from https://github.com/sindresorhus/refined-github/issues/1499. Of the repro cases I provided there

URLs appear to not be linked even if the URL _as a whole_ was added (first example), or even if they're just in comments alongside changes (second example—note that I unfolded the top of the diff to get there, not sure if that matters).

URLs do appear to be linked if they're in non-PR code blocks (third example).

The first is fixed with https://github.com/sindresorhus/refined-github/pull/2066, and the third remains fixed, but the second is still broken.

I can repro both if I visit the unfolded part directly (link) and if I go to the folded diff (link), then unfold the top (one unfold should be sufficient to see the link, at line 51).

Not sure if this is a regression or no.

bug help wanted

All 7 comments

Yeah this was never supported, it would be good to support it if there's a simple event to listen to. The same goes for all other features that work on diffs/code

it would be good to support it if there's a simple event to listen to

You mean like an event for more code becoming visible on-screen? Hm… I don't know what kind of events you might be thinking of. I guess my first approach would be to detect clicks on the fold/unfold buttons and re-run any diff-processing logic after that. Probably also good to do the same after the user clicks the "this diff is too long, click to expand" button for default-collapsed files.

GitHub fires their own events, like “load” and whatnot. Someone needs to find out by looking into their code (using dom breakpoints in chrome)

https://github.com/sindresorhus/refined-github/pull/2073/files#diff-ed524e4099f52cf2d11f30949a25d4e5 should fix this right!?

Indeed!

@notlmn we missed that part at some point I guess. The link in this code is not auto-linked:

example

I thought that #2073 would fix this, but that wouldn't as on-pr-file-load was about handling events from entire file diffs being ajaxed. This issue requires us to listen on clicks in the "diff expander" links being clicked on and run linkify-code to be run again.

But that might not be enough, as linkify-code adds .rgh-linkified-code class to the entire file diff element, that might prevent us from running linkify-code on the same file diff again, which might linkify already linkified code blocks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sindresorhus picture sindresorhus  ·  3Comments

olso picture olso  ·  3Comments

yakov116 picture yakov116  ·  3Comments

durka picture durka  ·  3Comments

hkdobrev picture hkdobrev  ·  3Comments