Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_hjm_a
杨树林 5 years ago
commit 9ed6d4ff33

@ -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

Loading…
Cancel
Save