diff --git a/app/services/create_diff_record_service.rb b/app/services/create_diff_record_service.rb index 87f3d0b24..8365404e2 100644 --- a/app/services/create_diff_record_service.rb +++ b/app/services/create_diff_record_service.rb @@ -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 + index = 0 + arr << line + arr.shift if arr.size > fragment_size + end + next + end + content += arr.join('') if arr.present? content += line + arr.clear end content end