Copying code to clipboard omits empty lines in some files #7587

Closed
opened 2025-11-02 07:30:37 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @silverwind on GitHub (Jul 15, 2021).

On some files like https://try.gitea.io/silverwind/symlink-test/src/branch/master/.drone.yml copying to clipboard via text selection omits emty lines in the copied content. The HTML of those empty lines does not render anything and I think we'd need to render a newline character for such empty lines so browser selection can properly pick it up. The issue does not show in all files and I think it's somehow caused by the yaml syntax highlighting.

On gitea (no newline character):

<code class="code-inner"><span class="w"></span></code>

On github (with newline character):

<td id="LC4" class="blob-code blob-code-inner js-file-line">
</td>
Originally created by @silverwind on GitHub (Jul 15, 2021). On some files like https://try.gitea.io/silverwind/symlink-test/src/branch/master/.drone.yml copying to clipboard via text selection omits emty lines in the copied content. The HTML of those empty lines does not render anything and I think we'd need to render a newline character for such empty lines so browser selection can properly pick it up. The issue does not show in all files and I think it's somehow caused by the yaml syntax highlighting. On gitea (no newline character): ```html <code class="code-inner"><span class="w"></span></code> ``` On github (with newline character): ```html <td id="LC4" class="blob-code blob-code-inner js-file-line"> </td> ```
GiteaMirror added the topic/uitype/bug labels 2025-11-02 07:30:37 -06:00
Author
Owner

@silverwind commented on GitHub (Jul 15, 2021):

Also of note, in diff view it works fine and the newline is there. Also there is no empty w span introduced by syntax highlighting which may be the culprit.

<code class="code-inner">
</code>
@silverwind commented on GitHub (Jul 15, 2021): Also of note, in [diff view](https://try.gitea.io/silverwind/symlink-test/commit/131deeb35ebe27bf86ea9f1c65153cd1634736ea) it works fine and the newline is there. Also there is no empty `w` span introduced by syntax highlighting which may be the culprit. ```html <code class="code-inner"> </code>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7587