sindresorhus/refined-github

allow multiline selection in diff view without having both views intermingled #2765

timotheecour posted onGitHub

This feature request is to allow multiline selection in diff view without having both views intermingled. Basically, exactly what's described here: https://stackoverflow.com/questions/48446463/how-to-cleanly-clipboard-copy-code-from-a-github-com-diff

Is that even possible within the extension or would that require upstream github changes?


This is almost impossible, unless there’s a way to exclude text from selection exactly before the copy happens. Maybe something like:

on before copy
  Start/end selection position determine which side user intends to select
  apply user-select: none on the other side
  setTimeout undo user-select change 
posted by fregante about 5 years ago

would adding a button avoid having to mess with timeout? then i'm assuming it's a matter of post-processing the clipboard so that it'd strip from each line the right half (or left half), modulo edge cases

posted by timotheecour about 5 years ago

I would be less comfortable post-process the clipboard, if anything changes we might end up removing something we don’t want. If this can be done “natively” with CSS then it might just work

posted by fregante about 5 years ago

Preliminary testing shows that this is feasible and relatively easy too. PR welcome.

Instead of "on before copy" I'd use mousedown/mouseup instead because, once the text is selected, applying user-select doesn't deselect it

posted by fregante over 4 years ago

is it not possible with reorder the html elements?

instead of each row includes both versions then there would be an element which holds all the left column (and there the rows) and a right column.

then a selection would select only the left or the right part.

posted by muescha over 4 years ago

an other idea:

when i like to copy the right or the left part, then i have a button like: show only right or left, then user can copy the text

posted by muescha over 4 years ago

i should read better the comments before: i think the user-select: none is the better way to go

posted by muescha over 4 years ago

once the text is selected, applying user-select doesn't deselect it

applying and removing the user-select: none changes the selected text (on my macoS Chrome)

posted by muescha over 4 years ago

Fund this Issue

$0.00
Funded

Pull requests