Defect #36580
closedFix code copying in common browsers
0%
Description
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.
Files
Related issues
Updated by Go MAEDA over 2 years ago
- File safari-without-patch.png safari-without-patch.png added
- File safari-with-patch.png safari-with-patch.png added
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:
after:
Updated by Vitaly vit9696 over 2 years ago
- File Screenshot 2022-02-08 at 14.01.31.png Screenshot 2022-02-08 at 14.01.31.png added
- File Screenshot 2022-02-08 at 14.04.50.jpg Screenshot 2022-02-08 at 14.04.50.jpg added
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
<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>
- Could you also post computed CSS for the
div
element? I attached mine on the screenshot to get an idea what I need
Updated by Go MAEDA over 2 years ago
- Assignee deleted (
Go MAEDA) - Target version set to 5.0.0
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 by Go MAEDA over 2 years ago
- File 36580-v2.patch 36580-v2.patch added
Updated the patch to include fixes for existing tests.
Updated by Yuichi HARADA over 2 years ago
- File 36580-v3.patch 36580-v3.patch added
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.
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
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
Updated by Go MAEDA over 2 years ago
- Related to Feature #3382: Ability to select only source code without line numbers added
Updated by Go MAEDA over 2 years ago
- Status changed from New to Closed
- Assignee set to Go MAEDA
Committed the patch. Thank you.