57 lines
3.1 KiB
Plaintext
57 lines
3.1 KiB
Plaintext
/ Side-by-side diff view
|
|
|
|
.text-file{ data: diff_view_data }
|
|
%table.diff-wrap-lines.code.code-commit.js-syntax-highlight
|
|
- diff_file.parallel_diff_lines.each do |line|
|
|
- left = line[:left]
|
|
- right = line[:right]
|
|
- discussions_left, discussions_right = parallel_diff_discussions(left, right, diff_file)
|
|
%tr.line_holder.parallel
|
|
- if left
|
|
- case left.type
|
|
- when 'match'
|
|
= diff_match_line left.old_pos, nil, text: left.text, view: :parallel
|
|
- when 'old-nomappinginraw', 'new-nomappinginraw', 'unchanged-nomappinginraw'
|
|
= diff_nomappinginraw_line left, %w[old_line diff-line-num], nil, %w[line_content parallel left-side]
|
|
- when 'old-nonewline', 'new-nonewline'
|
|
%td.old_line.diff-line-num
|
|
%td.line_content.match.left-side= left.text
|
|
- else
|
|
- left_line_code = diff_file.line_code(left)
|
|
- left_position = diff_file.position(left)
|
|
%td.old_line.diff-line-num.js-avatar-container{ class: left.type, data: { linenumber: left.old_pos } }
|
|
= add_diff_note_button(left_line_code, left_position, 'old')
|
|
%a{ href: "##{left_line_code}", data: { linenumber: left.old_pos } }
|
|
%td.line_content.parallel.left-side{ id: left_line_code, class: left.type }= diff_line_content(left.rich_text)
|
|
- else
|
|
%td.old_line.diff-line-num.empty-cell
|
|
%td.line_content.parallel.left-side
|
|
|
|
- if right
|
|
- case right.type
|
|
- when 'match'
|
|
= diff_match_line nil, right.new_pos, text: left.text, view: :parallel
|
|
- when 'old-nomappinginraw', 'new-nomappinginraw', 'unchanged-nomappinginraw'
|
|
= diff_nomappinginraw_line right, %w[new_line diff-line-num], nil, %w[line_content parallel right-side]
|
|
- when 'old-nonewline', 'new-nonewline'
|
|
%td.new_line.diff-line-num
|
|
%td.line_content.match.right-side= right.text
|
|
- else
|
|
- right_line_code = diff_file.line_code(right)
|
|
- right_position = diff_file.position(right)
|
|
%td.new_line.diff-line-num.js-avatar-container{ class: right.type, data: { linenumber: right.new_pos } }
|
|
= add_diff_note_button(right_line_code, right_position, 'new')
|
|
%a{ href: "##{right_line_code}", data: { linenumber: right.new_pos } }
|
|
%td.line_content.parallel.right-side{ id: right_line_code, class: right.type }= diff_line_content(right.rich_text)
|
|
- else
|
|
%td.old_line.diff-line-num.empty-cell
|
|
%td.line_content.parallel.right-side
|
|
|
|
- if discussions_left || discussions_right
|
|
= render "discussions/parallel_diff_discussion", discussions_left: discussions_left, discussions_right: discussions_right
|
|
- if !diff_file.new_file? && !diff_file.deleted_file? && diff_file.diff_lines.any?
|
|
- last_line = diff_file.diff_lines.last
|
|
- if last_line.new_pos < total_lines
|
|
%tr.line_holder.parallel
|
|
= diff_match_line last_line.old_pos, last_line.new_pos, bottom: true, view: :parallel
|