-- Main input to buffer.

function ChangeBuffer:align(diff: Diff): ()
	local s = diff[2]

	if s:match("\n") then
		local substrings = s:split("\n")
		-- ROBLOX deviation: 1-indexing
		local iLast = #substrings
		for i, substring in ipairs(substrings) do
			if i < iLast then
				-- The first substring completes the current change line.
				-- A middle substring is a change line.
				self:pushSubstring(substring)
				self:pushLine()
			elseif #substring ~= 0 then
				-- The last substring starts a change line, if it is not empty.
				-- Important: This non-empty condition also automatically omits
				-- the newline appended to the end of expected and received strings.
				self:pushSubstring(substring)
			end
		end
	else
		-- Append non-multiline string to current change line.
		self:pushDiff(diff)
	end
end
