-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add single-diff-column-selection
feature
#3698
Add single-diff-column-selection
feature
#3698
Conversation
Oh hell yeah. Put a 🔥 in the readme description. |
A few notes: I’d suggest handling the CSS with a single class. For example you can apply a You can probably merge the two delegated events into one, a just detect which side was selected in the handler. You can use element.closest('tbody') instead of that function with a loop 🎉 Make sure this only applies when the diff is split, not unified. |
Or instead of the class, you can use a data-rgh-select=right attribute for example, so removing it means always |
I don’t think that the alternative is particularly better, the copied text would just be missing part of code without any indication of it. |
I applied your suggestions @fregante, the code is much cleaner now. |
Co-authored-by: Federico <me@fregante.com>
Co-authored-by: Federico <me@fregante.com>
single-diff-column-selection
feature
I can't reproduce it neither in Firefox nor Chromium, so it might be a Chrome bug. |
I think I got it. The current code covers all the cases and works in both Firefox and Chrome. Try it out and let me know if you see any issues. |
It's working great, nicely done! 💯 The only (tiny) snag I saw was that dragging the selection in Chromium ends up taking both sides of the diff with it. This doesn't happen in Firefox though, so it's probably a browser-specific bug. |
It shows both sides, but only our side is eventually pasted (at least on Mac) I looked into ways to properly exclude the selection, but multi-cursor selection isn't supported in Chrome. Short of fully detaching those DOM nodes, I don't see another way. Hey, if copy/paste works, that's already better than now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 thank you so much.
This is awesome!!
@sindresorhus I think this deserves a tweet. This was such a pain point of using GitHub diff in split view.
@cheap-glitch I updated the extension but it doesn't seem to work, do you need to tag a new release first? |
There will be a release tomorrow |
Thanks for contributing! 🍄
LINKED ISSUES: Closes allow multiline selection in diff view without having both views intermingled #2765
TEST URLS: https://github.com/sindresorhus/refined-github/pull/3695/files
SCREENSHOT:
Not sure if this is the best approach for this, but it works. Side note: should we also disable selection on "expandable lines" too? The ones in the middle of files can end up being selected, which is probably not what the user wants.
EDIT: There was some slight but noticeable lag with huge diffs, so I rewrote the feature to target one diff table at a time, since users will probably always copy from one file at a time.