-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Make diff line-marker non-selectable #7279
Make diff line-marker non-selectable #7279
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7279 +/- ##
==========================================
- Coverage 41.17% 41.15% -0.02%
==========================================
Files 464 464
Lines 62771 62763 -8
==========================================
- Hits 25846 25832 -14
Misses 33537 33537
- Partials 3388 3394 +6
Continue to review full report at Codecov.
|
While testing this I found out that while webkit obeys the "don't select" part, it still copies the contents if something around it has been selected: Then the copied text is:
This appears to be an old issue unfortunately, https://bugs.webkit.org/show_bug.cgi?id=80159 I don't have this issue on Github or other similar sites, so I tried to see what was different: It appears Github gets this to work through adding the line numbers and +/- using a pseudo class, like:
Probably similar to what @silverwind was mentioning in the linked Issue. I tried to create a really small example of how this might look to see if it would work on Safari and it does seem to: https://codepen.io/mrsdizzie/pen/agWNwL Knowledge of HTML/CSS is pretty limited though |
@mrsdizzie OK done. |
public/css/index.css
Outdated
@@ -465,6 +465,7 @@ footer .ui.left,footer .ui.right{line-height:40px} | |||
.repository.file.list .non-diff-file-content .code-view table{width:100%} | |||
.repository.file.list .non-diff-file-content .code-view .lines-num{vertical-align:top;text-align:right;color:#999;background:#f5f5f5;width:1%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none} | |||
.repository.file.list .non-diff-file-content .code-view .lines-num span{line-height:20px;padding:0 10px;cursor:pointer;display:block} | |||
.repository.file.list .non-diff-file-content .code-view .lines-num[data-line-num]::before{content:attr(data-line-num);display:inline-block} |
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.
Should this have been in .diff-file-box not .non-diff-file-content ? Or maybe it belongs in both? I don't see the line numbers in a commit diff with the latest push
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.
Damn you're right. Don't know how I missed that.
Aside from the comment above about line numbers the copy/paste now works in Safari, thanks!! Also this is totally non blocking but since you are changing it: I think it would nice if the +/- were in their own as well, since it would/could give a bit more padding like in most the diffs here on Github (but not the comments on diffs strangely). Also on Safari when it is part of the same content it still lets you visually select the +/- chars on lines that also have selectable text, which might make people think that it will copy them as well. It doesn't actually copy them any more so the real problem is solved and that is just a slight cosmetic issue at that point. Could be done in a separate PR if needed though. |
OK @mrsdizzie I think that's done |
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.
Nice, looks great!
make lg-tm work |
Thanks, the |
Hmm is that new? I haven't actually changed the template part that renders the code line. |
I think previously it was 3 newlines per line, with the introduction of |
* Make diff line-marker non-selectable * Move to use data-* as per @mrsdizzie * fix missing line nums * Add a minimum-width to force right-align of the line num * Move line-type-marker into separate column
This PR makes the first character of the diff line non-selectable.
Fixes #4076