-
-
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
fix extra newlines when copying from diff in Firefox #7288
Conversation
See https://bugzilla.mozilla.org/show_bug.cgi?id=1273836 Basically, the <pre><code> seems to add a forced newline that is not possible to get rid of via CSS, so I replaced it with just a <code>. Secondly, .lines-type-marker also forced a newline in the copied text, but that was possible to get rid of via user-select. Safari still has a extraneous newline in the copied text of unknown origin, but this should not block stop this PR.
Codecov Report
@@ Coverage Diff @@
## master #7288 +/- ##
==========================================
- Coverage 41.24% 41.24% -0.01%
==========================================
Files 464 464
Lines 62841 62846 +5
==========================================
+ Hits 25917 25918 +1
- Misses 33533 33537 +4
Partials 3391 3391
Continue to review full report at Codecov.
|
Fixed that by removing the This removes the extra newlines that Safari copies as well. Safari still has a issue with weird indendation being copied, thought. |
I had assumed that the pre was there for a reason that's why I left it in. |
|
Noticed an issue with content being absent in the split diff, will fix that later and also investigate Safari. |
Damn it's not copying the data-line-num either. |
OK fixed that too. I'll stop hammering your PR now. |
Wow, good find. Would never have imagined we would have sneaky JS embedded in template code. Very bad practice imho. I will give this PR another run of tests tomorrow, pretty sure a few fixups will be needed, so please don't merge yet, unless this fix is deemed critical (for a release). |
Won't approve yet based on last comment, but my initial padding/alignment issue seems fixed and all of the fixes for the split view seem OK and that appears to be working as it was before. Also agree a real "wtf" for this template. |
Yeah that's probably why I missed it. That the comment box template is also stored in index.is is also unexpected too. It should not be this fiddly to adjust the diff format! Diff was already on my naughty list, but it might just have risen a bit higher. Once again I'm so sorry for messing this up. I really did not expect it to be so fragile! |
Co-Authored-By: zeripath <art27@cantab.net>
Fixed that Safari copy/paste issue. Turns out it was tripping on the whitespace between HTML tags which I've now removed. It makes the template a bit uglier to read but it unfortunately is neccesary. Does not look like go template has any built-in way to auto-strip whitespace around tags. So this PR should be ready for review. It contains a important fix for the split diff among the copy/paste fixes for Firefox and Safari. |
It seems to not copy any newlines now, even intentional ones: So a diff like this:
Would get copied as
|
You're right. It seems we need to render a |
@mrsdizzie should be fixed as of last commit. |
I'm being a muppet! |
@silverwind thank you so much for fixing my idiotic broken PR. I'm so sorry once again for so many problems. I can't understand how I missed how broken it was. |
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.
Looks good thanks again @silverwind for going beyond the initial scope of this to help fix everything!
@silverwind are you happy with my last change. I think we will be able to merge if so. |
I'm happy if @mrsdizzie is happy 🤣 In hindsight, it would've probably been easier if you had opened a separate PR for those fixes, thought on the other hand, it was kind of convenient to have the fixes in the branch 😉 |
* fix extra newlines when copying from diff See https://bugzilla.mozilla.org/show_bug.cgi?id=1273836 Basically, the <pre><code> seems to add a forced newline that is not possible to get rid of via CSS, so I replaced it with just a <code>. Secondly, .lines-type-marker also forced a newline in the copied text, but that was possible to get rid of via user-select. Safari still has a extraneous newline in the copied text of unknown origin, but this should not block stop this PR. * simplify .line-type-marker * fix selector * remove erronous ^^^ * Fix empty split diff * Fix arc-theme-green * fix add comment * ensure line-num is copied too * Update templates/repo/diff/box.tmpl Co-Authored-By: zeripath <art27@cantab.net> * attempt to fix safari via removing <code> * remove useless whitespace at the end of 'class' * remove inter-tag whitespace for code <td>s * more inter-tag removal * final inter-tag removal * attempt to fix empty line copy * move and comment getLineContent * fix golint * make background grey for missing added code
Followup on #7279 to fix copy from diff in Firefox.
First, the
<pre><code>
seems to add a forced newline that is not possible to get rid of via CSS, so I replaced it with just a<code>
. Secondly,.lines-type-marker
also forced a newline in the copied text, but that was possible to get rid of viauser-select: none
.This should fix it for Firefox and Chrome. Safari still has a extraneous newline in the copied text of unknown origin, but this should not block stop this PR.
Also see https://bugzilla.mozilla.org/show_bug.cgi?id=1273836