-- Given change op and array of diffs, return concatenated string:
-- * include common strings
-- * include change strings which have argument op with changeColor
-- * exclude change strings which have opposite op

local function concatenateRelevantDiffs(op: number, diffs: Array<Diff>, changeColor: DiffOptionsColor): string
	return Array.reduce(diffs, function(reduced, diff)
		if diff[1] == DIFF_EQUAL then
			return reduced .. diff[2]
		elseif diff[1] == op and #diff[2] ~= 0 then -- empty if change is newline
			return reduced .. changeColor(diff[2])
		end
		return reduced .. ""
	end, "")
end

export type ChangeBuffer = {
	op: number,
	line: Array<Diff>,
	lines: Array<Diff>,
	changeColor: DiffOptionsColor,
	pushSubstring: (self: ChangeBuffer, substring: string) -> (),
	pushLine: (self: ChangeBuffer) -> (),
	isLineEmpty: (self: ChangeBuffer) -> boolean,
	pushDiff: (self: ChangeBuffer, diff: Diff) -> (),
	align: (self: ChangeBuffer, diff: Diff) -> (),
	moveLinesTo: (self: ChangeBuffer, lines: Array<Diff>) -> (),
}
