summaryrefslogtreecommitdiff
path: root/app/models/discussion.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2016-11-17 22:22:39 +0000
committerSean McGivern <sean@gitlab.com>2016-11-28 19:40:48 +0000
commit854fbbfb07b84394cc952d0ae20b7f29957e6555 (patch)
treecd6ba08f6a0a1d2205a1ef651e4cba8ba7f35a9b /app/models/discussion.rb
parent938de31167e262cb3eb952f6be1797b4c891d34c (diff)
downloadgitlab-ce-854fbbfb07b84394cc952d0ae20b7f29957e6555.tar.gz
Tidy up text emails
Diffstat (limited to 'app/models/discussion.rb')
-rw-r--r--app/models/discussion.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/discussion.rb b/app/models/discussion.rb
index 9bd37fe6d89..75a85563235 100644
--- a/app/models/discussion.rb
+++ b/app/models/discussion.rb
@@ -165,18 +165,21 @@ class Discussion
# Returns an array of at most 16 highlighted lines above a diff note
def truncated_diff_lines(highlight: true)
- initial_lines = highlight ? highlighted_diff_lines : diff_lines
+ lines = highlight ? highlighted_diff_lines : diff_lines
prev_lines = []
- initial_lines.each do |line|
+ lines.each do |line|
if line.meta?
prev_lines.clear
else
prev_lines << line
+
break if for_line?(line)
+
prev_lines.shift if prev_lines.length >= NUMBER_OF_TRUNCATED_DIFF_LINES
end
end
+
prev_lines
end