diff options
author | Robert Speicher <robert@gitlab.com> | 2016-01-22 07:37:47 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-01-22 07:37:47 +0000 |
commit | 2fed8bf390aa89a854ac5452aa934076cd426a81 (patch) | |
tree | bca5a3fe0d321424fe6755ab8441485594ef1c7d /lib | |
parent | 87867018f3157c617e489c5edbd127055571b11f (diff) | |
parent | 3db24ec9e80369834ccf7d2423808fcf5e51b5a6 (diff) | |
download | gitlab-ce-2fed8bf390aa89a854ac5452aa934076cd426a81.tar.gz |
Merge branch 'fix-diff-comments' into 'master'
More highlighted diff fixes
See merge request !2545
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/diff/highlight.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/diff/parallel_diff.rb | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb index 9283b5e185d..a7f925ce134 100644 --- a/lib/gitlab/diff/highlight.rb +++ b/lib/gitlab/diff/highlight.rb @@ -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 diff --git a/lib/gitlab/diff/parallel_diff.rb b/lib/gitlab/diff/parallel_diff.rb index c0db3559e3a..74f9b3c050a 100644 --- a/lib/gitlab/diff/parallel_diff.rb +++ b/lib/gitlab/diff/parallel_diff.rb @@ -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 |