Commit 1164e008 authored by Phil Hughes's avatar Phil Hughes

Fixed bug service finding wrong diff line index

Fixes a bug where if the change is after the first line in a file
the outdated diff lines service would find the incorrect starting
index and then return an incorrect diff.
parent 7b03b44b
......@@ -15,7 +15,13 @@ module MergeRequests
def execute
end_position = position.line_range["end"]
diff_line_index = diff_lines.find_index { |l| l.new_line == end_position["new_line"] || l.old_line == end_position["old_line"] }
diff_line_index = diff_lines.find_index do |l|
if end_position["new_line"]
l.new_line == end_position["new_line"]
elsif end_position["old_line"]
l.old_line == end_position["old_line"]
end
end
initial_line_index = [diff_line_index - OVERFLOW_LINES_COUNT, 0].max
last_line_index = [diff_line_index + OVERFLOW_LINES_COUNT, diff_lines.length].min
......
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