summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-01-22 02:10:58 +0100
committerDouwe Maan <douwe@selenight.nl>2016-01-22 02:10:58 +0100
commit16d17b78cabe2efd762a4aa0e9fa2c2792fab32d (patch)
treef64c072cd4ce4944f2d8a5c15e9812b78a574a41
parent3f7993b5ceb9c5ba616dffef39f9b535482d92c1 (diff)
downloadgitlab-ce-16d17b78cabe2efd762a4aa0e9fa2c2792fab32d.tar.gz
Restore diff comments
-rw-r--r--app/views/projects/diffs/_text_file.html.haml3
-rw-r--r--lib/gitlab/diff/highlight.rb9
2 files changed, 7 insertions, 5 deletions
diff --git a/app/views/projects/diffs/_text_file.html.haml b/app/views/projects/diffs/_text_file.html.haml
index f4fc6caba0f..2e329a823a6 100644
--- a/app/views/projects/diffs/_text_file.html.haml
+++ b/app/views/projects/diffs/_text_file.html.haml
@@ -6,6 +6,7 @@
%table.text-file.code.js-syntax-highlight{ class: too_big ? 'hide' : '' }
- last_line = 0
+ - raw_diff_lines = diff_file.diff_lines
- diff_file.highlighted_diff_lines.each_with_index do |line, index|
- type = line.type
- last_line = line.new_pos
@@ -31,7 +32,7 @@
- if @reply_allowed
- comments = @line_notes.select { |n| n.line_code == line_code && n.active? }.sort_by(&:created_at)
- unless comments.empty?
- = render "projects/notes/diff_notes_with_reply", notes: comments, line: line.text
+ = render "projects/notes/diff_notes_with_reply", notes: comments, line: raw_diff_lines[index].text
- if last_line > 0
= render "projects/diffs/match_line", {line: "",
diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb
index 179f8164c84..ac8537ad31a 100644
--- a/lib/gitlab/diff/highlight.rb
+++ b/lib/gitlab/diff/highlight.rb
@@ -12,9 +12,10 @@ module Gitlab
end
def highlight
- @diff_lines.each_with_index do |diff_line, i|
+ @diff_lines.map.with_index do |diff_line, i|
+ diff_line = diff_line.dup
# ignore highlighting for "match" lines
- next if diff_line.type == 'match' || diff_line.type == 'nonewline'
+ next diff_line if diff_line.type == 'match' || diff_line.type == 'nonewline'
rich_line = highlight_line(diff_line, i)
@@ -23,9 +24,9 @@ module Gitlab
end
diff_line.text = rich_line.html_safe
- end
- @diff_lines
+ diff_line
+ end
end
private