diff options
author | Rubén Dávila <rdavila84@gmail.com> | 2015-12-30 21:44:12 -0500 |
---|---|---|
committer | Rubén Dávila <rdavila84@gmail.com> | 2015-12-30 21:44:12 -0500 |
commit | fd100e1ef1726418c81ab8833cf8bcf86fab6eef (patch) | |
tree | 22284ca91f52d9042479d14a89101092ab281b12 | |
parent | 8b079315d98a8ccf852592148632c6f052d9cb55 (diff) | |
download | gitlab-ce-fd100e1ef1726418c81ab8833cf8bcf86fab6eef.tar.gz |
Don't modify "match" diff lines. #3945
-rw-r--r-- | lib/gitlab/diff/highlight.rb | 7 | ||||
-rw-r--r-- | spec/lib/gitlab/diff/highlight_spec.rb | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb index 40a54ede2bb..c780ea21775 100644 --- a/lib/gitlab/diff/highlight.rb +++ b/lib/gitlab/diff/highlight.rb @@ -25,7 +25,12 @@ module Gitlab def update_diff_lines @highlighted_code.lines.each_with_index do |line, i| - @diff_lines[i].text = "#{@diff_line_prefixes[i]}#{line}" + diff_line = @diff_lines[i] + + # ignore highlighting for "match" lines + next if diff_line.type == 'match' + + diff_line.text = "#{@diff_line_prefixes[i]}#{line}" end @diff_lines diff --git a/spec/lib/gitlab/diff/highlight_spec.rb b/spec/lib/gitlab/diff/highlight_spec.rb index 80083c15cff..54621f773d7 100644 --- a/spec/lib/gitlab/diff/highlight_spec.rb +++ b/spec/lib/gitlab/diff/highlight_spec.rb @@ -24,5 +24,10 @@ describe Gitlab::Diff::Highlight, lib: true do it 'should keep the inline diff markup' do expect(diff_lines[5].text).to match(Regexp.new(Regexp.escape('<span class="idiff">RuntimeError, </span>'))) end + + it 'should not modify "match" lines' do + expect(diff_lines[0].text).to eq('@@ -6,12 +6,18 @@ module Popen') + expect(diff_lines[22].text).to eq('@@ -19,6 +25,7 @@ module Popen') + end end end |