Vote #81816
完了Fix code copying in common browsers
0%
説明
This patch resolves https://www.redmine.org/issues/3382 for:
- Chrome-based browsers (empty lines do not get copied).
- Safari (line numbers are inserted to the copied code, empty lines do not get copied, extra spaces are inserted before each line).
- Firefox (empty lines are inserted to the copied code).
As for Chrome and Safari the only way to make them properly copy empty newlines is to insert a "br" element instead of "pre".
As for Safari, data marked as user-select none will still be copied, thus the content trick used in other SCM apps. It is additionally important to put "a" element right after "th", because otherwise there will be spaces in front of the line.
As for Firefox, there are multiple related issues in their bugtracker:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1273836
- https://bugzilla.mozilla.org/show_bug.cgi?id=1528442
- https://bugzilla.mozilla.org/show_bug.cgi?id=1650720 And the only solution seems to mimic pre with div.
journals
Thank you for posting the patch that fixes the issue that has not been fixed for years.
However, I found an issue with Safari that all preceding white spaces of a line are stripped.
*before:*
!{border: 1px solid grey; width: 265px;}.safari-without-patch.png!
*after:*
!{border: 1px solid grey; width: 232px;}.safari-with-patch.png!
--------------------------------------------------------------------------------
Thanks for testing, but I am afraid I need more details about the issue, because it works fine on macOS 12.2 with the latest Safari for me.
* What Safari version do you have?
* Could you post the source of the file?
* Could you post HTML source of page? Could do both the whole part of just the important part. E.g. I have
<pre>
<div> <span class="k">union</span> <span class="n">ldshape</span> <span class="n">u</span> <span class="o">=</span> <span class="p">{</span><span class="n">x</span><span class="p">};</span>
</div>
</pre>
* Could you also post computed CSS for the @div@ element? I attached mine on the screenshot to get an idea what I need
--------------------------------------------------------------------------------
Maeda-san, could you clarify this?
--------------------------------------------------------------------------------
I found that the "issue" I reported in #36580#note-1 was due to browser cache. Super reload resolved the issue. I am very sorry for bothering you.
Setting the target version to 5.0.0.
--------------------------------------------------------------------------------
Updated the patch to include fixes for existing tests.
--------------------------------------------------------------------------------
Go MAEDA wrote:
> Updated the patch to include fixes for existing tests.
The test in test/functional/repositories_cvs_controller_test.rb failed, so I fixed the test and added it to 36580-v2.patch.
<pre>
Failure:
RepositoriesCvsControllerTest#test_annotate [test/functional/repositories_cvs_controller_test.rb:285]:
<21> expected but was
<>..
Expected 0 to be >= 1.
rails test test/functional/repositories_cvs_controller_test.rb:268
</pre>
<pre><code class="diff">
diff --git a/test/functional/repositories_cvs_controller_test.rb b/test/functional/repositories_cvs_controller_test.rb
index 09db1611a8..fdd8e986d1 100644
--- a/test/functional/repositories_cvs_controller_test.rb
+++ b/test/functional/repositories_cvs_controller_test.rb
@@ -283,13 +283,13 @@ class RepositoriesCvsControllerTest < Redmine::RepositoryControllerTest
# 1.1 line
assert_select 'tr' do
- assert_select 'th.line-num', :text => '21'
+ assert_select 'th.line-num a[data-txt=?]', '21'
assert_select 'td.revision', :text => /1.1/
assert_select 'td.author', :text => /LANG/
end
# 1.2 line
assert_select 'tr' do
- assert_select 'th.line-num', :text => '32'
+ assert_select 'th.line-num a[data-txt=?]', '32'
assert_select 'td.revision', :text => /1.2/
assert_select 'td.author', :text => /LANG/
end
</code></pre>
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Committed the patch. Thank you.
--------------------------------------------------------------------------------
related_issues
relates,Closed,3382,Ability to select only source code without line numbers