Commit 5ecd1a7c authored by Kerri Miller's avatar Kerri Miller

Merge branch 'ph/fixOutdatedDiffLinesLineNotFound' into 'master'

Fixes outdated diff lines returning incorrect results

See merge request gitlab-org/gitlab!76339
parents 55542258 63f18fb4
...@@ -15,12 +15,22 @@ module MergeRequests ...@@ -15,12 +15,22 @@ module MergeRequests
def execute def execute
line_position = position.line_range["end"] || position.line_range["start"] line_position = position.line_range["end"] || position.line_range["start"]
diff_line_index = diff_lines.find_index do |l| found_line = false
if line_position["new_line"] diff_line_index = -1
l.new_line == line_position["new_line"] diff_lines.each_with_index do |l, i|
elsif line_position["old_line"] if found_line
l.old_line == line_position["old_line"] if !l.type
break
elsif l.type == 'new'
diff_line_index = i
break
end
else
# Find the old line
found_line = l.old_line == line_position["new_line"]
end end
diff_line_index = i
end end
initial_line_index = [diff_line_index - OVERFLOW_LINES_COUNT, 0].max initial_line_index = [diff_line_index - OVERFLOW_LINES_COUNT, 0].max
last_line_index = [diff_line_index + OVERFLOW_LINES_COUNT, diff_lines.length].min 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