google / gitiles

A simple browser for Git repositories.
https://gerrit.googlesource.com/gitiles/
Other
582 stars 174 forks source link

Empty lines are not copied to the clipboard #130

Open rryk opened 6 years ago

rryk commented 6 years ago

When trying to view the file and copy its contents into clipboard (to be pasted as plain text elsewhere), the empty lines are not being copied. Although it's possible to access text view of the file by clicking on the "text" link below, it causes the file to be downloaded, which is suboptimal, since the user now needs to decipher the downloaded content from base64, open it in a local editor and then copy the content from there. For example, when selecting and copying first 10 lines from https://chromium.googlesource.com/infra/infra/+/7a4722137440999d5e0230a75edc8ad63463823b/infra/services/swarm_docker/containers.py, the text copied to clipboard is the following

# Copyright (c) 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from datetime import datetime
import docker
import logging
import os
import pwd
import requests

Note the missing empty line after the comment. I've also noticed that when pasting into a rich-text editor such as this issue, it copies pieces of the UI like this:

# Copyright (c) 2016 The Chromium Authors. All rights reserved.
--
  | # Use of this source code is governed by a BSD-style license that can be
  | # found in the LICENSE file.
  |  
  | from datetime import datetime
  | import docker
  | import logging
  | import os
  | import pwd
  | import requests

Therefore I suspect one would need to tweak HTML in a way that would allow just text to be selected and not the UI elements such as vertical line separating line numbers from text or even invisible horizontal line between first and following lines.