From 8303eb8a9e5f90b4b764ff3e094c743a12b0cfe4 Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Mon, 7 Jan 2019 19:12:30 -0200 Subject: Adjusts duplicated line when commenting on unfolded diff lines --- lib/gitlab/diff/lines_unfolder.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/diff/lines_unfolder.rb b/lib/gitlab/diff/lines_unfolder.rb index 9306b7e16a2..6cf904b2b2a 100644 --- a/lib/gitlab/diff/lines_unfolder.rb +++ b/lib/gitlab/diff/lines_unfolder.rb @@ -158,9 +158,14 @@ module Gitlab from = comment_position - UNFOLD_CONTEXT_SIZE - # There's no line before the match if it's in the top-most - # position. - prev_line_number = line_before_unfold_position&.old_pos || 0 + prev_line_number = + if bottom? + last_line.old_pos + else + # There's no line before the match if it's in the top-most + # position. + line_before_unfold_position&.old_pos || 0 + end if from <= prev_line_number + 1 @generate_top_match_line = false -- cgit v1.2.3