プロジェクト

全般

プロフィール

Vote #81816

完了

Fix code copying in common browsers

Admin Redmine さんが約2年前に追加. 約2年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Text formatting_26
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
155
issue_org_id:
36580
author_id:
78986
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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:


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

Admin Redmine さんが約2年前に更新

  • カテゴリText formatting_26 にセット
  • 対象バージョン5.0.0_155 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0