Commit 2fed8bf3 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fix-diff-comments' into 'master'

More highlighted diff fixes

See merge request !2545
parents 87867018 3db24ec9
......@@ -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: "",
......
......@@ -16,9 +16,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)
......@@ -27,9 +28,9 @@ module Gitlab
end
diff_line.text = rich_line.html_safe
end
@diff_lines
diff_line
end
end
private
......
......@@ -11,7 +11,8 @@ module Gitlab
lines = []
skip_next = false
diff_file.highlighted_diff_lines.each do |line|
highlighted_diff_lines = diff_file.highlighted_diff_lines
highlighted_diff_lines.each do |line|
full_line = line.text
type = line.type
line_code = generate_line_code(diff_file.file_path, line)
......@@ -21,6 +22,7 @@ module Gitlab
next_line = diff_file.next_line(line.index)
if next_line
next_line = highlighted_diff_lines[next_line.index]
next_line_code = generate_line_code(diff_file.file_path, next_line)
next_type = next_line.type
next_line = next_line.text
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment