summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnnabel Dunstone <annabel.dunstone@gmail.com>2016-04-08 14:43:21 -0700
committerAnnabel Dunstone <annabel.dunstone@gmail.com>2016-04-14 09:10:40 -0500
commit7030ffb0e09dbcc0d03d377846a04fe6cf7d20b6 (patch)
tree16ab8b091d7c315907cf06d9fbeb9920e28b82ea
parent64776ab2b4ef40519e75eb73ae946d2c1f774aa6 (diff)
downloadgitlab-ce-7030ffb0e09dbcc0d03d377846a04fe6cf7d20b6.tar.gz
Copying and pasting doesn't grab line numbers or +/-
-rw-r--r--app/assets/stylesheets/pages/diff.scss20
-rw-r--r--app/helpers/diff_helper.rb1
-rw-r--r--app/views/projects/blob/diff.html.haml6
-rw-r--r--app/views/projects/diffs/_line.html.haml6
4 files changed, 27 insertions, 6 deletions
diff --git a/app/assets/stylesheets/pages/diff.scss b/app/assets/stylesheets/pages/diff.scss
index d0855f66911..ca7fa2094b6 100644
--- a/app/assets/stylesheets/pages/diff.scss
+++ b/app/assets/stylesheets/pages/diff.scss
@@ -67,6 +67,14 @@
line-height: $code_line_height;
font-size: $code_font_size;
+ &.noteable_line.old:before {
+ content: '-';
+ }
+
+ &.noteable_line.new:before {
+ content: '+';
+ }
+
span {
white-space: pre;
}
@@ -391,3 +399,15 @@
margin-bottom: 0;
}
}
+
+.diff-line-num:not(.js-unfold-bottom) {
+ a {
+ &:before {
+ content: attr(data-linenumber);
+ }
+ -moz-user-select: none;
+ -webkit-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ }
+}
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index ff32e834499..f1e213b34e8 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -44,6 +44,7 @@ module DiffHelper
if line.blank?
" &nbsp;".html_safe
else
+ line[0] = ''
line
end
end
diff --git a/app/views/projects/blob/diff.html.haml b/app/views/projects/blob/diff.html.haml
index abcfca4cd11..ea6d4df7255 100644
--- a/app/views/projects/blob/diff.html.haml
+++ b/app/views/projects/blob/diff.html.haml
@@ -9,9 +9,9 @@
- line_old = line_new - @form.offset
%tr.line_holder
%td.old_line.diff-line-num{data: {linenumber: line_old}}
- = link_to raw(line_old), "#"
- %td.new_line.diff-line-num
- = link_to raw(line_new) , "#"
+ / = link_to raw(line_old), "#"
+ %td.new_line.diff-line-num{data: {linenumber: line_old}}
+ / = link_to raw(line_new) , "#"
%td.line_content.noteable_line==#{' ' * @form.indent}#{line}
- if @form.unfold? && @form.bottom? && @form.to < @blob.loc
diff --git a/app/views/projects/diffs/_line.html.haml b/app/views/projects/diffs/_line.html.haml
index 9464c8dc996..2dc6f548437 100644
--- a/app/views/projects/diffs/_line.html.haml
+++ b/app/views/projects/diffs/_line.html.haml
@@ -9,12 +9,12 @@
%td.new_line.diff-line-num
%td.line_content.match= line.text
- else
- %td.old_line.diff-line-num{class: type}
+ %td.old_line.diff-line-num{class: type, data: {linenumber: line.new_pos}}
- link_text = raw(type == "new" ? "&nbsp;" : line.old_pos)
- if defined?(plain) && plain
= link_text
- else
- = link_to link_text, "##{line_code}", id: line_code
+ = link_to "", "##{line_code}", id: line_code, data: { linenumber: link_text }
- if @comments_allowed && can?(current_user, :create_note, @project)
= link_to_new_diff_note(line_code)
%td.new_line.diff-line-num{class: type, data: {linenumber: line.new_pos}}
@@ -22,5 +22,5 @@
- if defined?(plain) && plain
= link_text
- else
- = link_to link_text, "##{line_code}", id: line_code
+ = link_to "", "##{line_code}", id: line_code, data: { linenumber: link_text }
%td.line_content{class: "noteable_line #{type} #{line_code}", data: { line_code: line_code }}= diff_line_content(line.text)