Commit 254dbad8 authored by Douwe Maan's avatar Douwe Maan Committed by Fatih Acet

Fix bug where conflict view would have one too many context sections

parent 83925ef4
...@@ -72,9 +72,11 @@ module Gitlab ...@@ -72,9 +72,11 @@ module Gitlab
def sections def sections
return @sections if @sections return @sections if @sections
chunked_lines = lines.chunk { |line| line.type.nil? } chunked_lines = lines.chunk { |line| line.type.nil? }.to_a
match_line = nil match_line = nil
sections_count = chunked_lines.size
@sections = chunked_lines.flat_map.with_index do |(no_conflict, lines), i| @sections = chunked_lines.flat_map.with_index do |(no_conflict, lines), i|
section = nil section = nil
...@@ -82,7 +84,7 @@ module Gitlab ...@@ -82,7 +84,7 @@ module Gitlab
# always shown in full. # always shown in full.
if no_conflict if no_conflict
conflict_before = i > 0 conflict_before = i > 0
conflict_after = chunked_lines.peek conflict_after = (sections_count - i) > 1
if conflict_before && conflict_after if conflict_before && conflict_after
# Create a gap in a long context section. # Create a gap in a long context section.
......
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