@ -20,10 +20,26 @@ class CreateDiffRecordService < ApplicationService
def diff_content
content = ''
arr = []
index = 0
fragment_size = 1
Diffy::Diff.new(before, after).each do |line|
next unless line =~ /^[\+-]/
unless line =~ /^[\+-]/
if arr.empty? && index < fragment_size
content += line
index += 1
else
arr << line
arr.shift if arr.size > fragment_size
end
next
content += arr.join('') if arr.present?
arr.clear
content