2013-11-27 03:00:14 -05:00
|
|
|
/ Side-by-side diff view
|
2017-06-12 14:43:21 -04:00
|
|
|
|
2019-03-23 09:22:16 -04:00
|
|
|
.text-file{ data: diff_view_data }
|
2019-06-06 11:51:04 -04:00
|
|
|
%table.diff-wrap-lines.code.code-commit.js-syntax-highlight
|
2016-01-20 08:51:56 -05:00
|
|
|
- diff_file.parallel_diff_lines.each do |line|
|
2016-01-14 08:52:08 -05:00
|
|
|
- left = line[:left]
|
|
|
|
- right = line[:right]
|
2017-03-31 19:39:14 -04:00
|
|
|
- discussions_left, discussions_right = parallel_diff_discussions(left, right, diff_file)
|
2016-07-01 01:09:56 -04:00
|
|
|
%tr.line_holder.parallel
|
2016-07-20 18:18:18 -04:00
|
|
|
- if left
|
2017-01-18 17:40:34 -05:00
|
|
|
- case left.type
|
|
|
|
- when 'match'
|
2016-07-21 14:44:12 -04:00
|
|
|
= diff_match_line left.old_pos, nil, text: left.text, view: :parallel
|
2017-03-13 16:09:43 -04:00
|
|
|
- when 'old-nonewline', 'new-nonewline'
|
2017-01-18 17:40:34 -05:00
|
|
|
%td.old_line.diff-line-num
|
2017-09-28 10:55:25 -04:00
|
|
|
%td.line_content.match.left-side= left.text
|
2016-07-20 18:18:18 -04:00
|
|
|
- else
|
|
|
|
- left_line_code = diff_file.line_code(left)
|
|
|
|
- left_position = diff_file.position(left)
|
2017-09-28 10:55:25 -04:00
|
|
|
%td.old_line.diff-line-num.js-avatar-container{ class: left.type, data: { linenumber: left.old_pos } }
|
2017-06-12 14:43:21 -04:00
|
|
|
= add_diff_note_button(left_line_code, left_position, 'old')
|
2017-01-22 19:07:41 -05:00
|
|
|
%a{ href: "##{left_line_code}", data: { linenumber: left.old_pos } }
|
2019-03-23 09:34:08 -04:00
|
|
|
%td.line_content.parallel.left-side{ id: left_line_code, class: left.type }= diff_line_content(left.rich_text)
|
2016-01-14 08:52:08 -05:00
|
|
|
- else
|
2016-07-20 18:18:18 -04:00
|
|
|
%td.old_line.diff-line-num.empty-cell
|
2017-09-28 10:55:25 -04:00
|
|
|
%td.line_content.parallel.left-side
|
2014-09-12 12:43:44 -04:00
|
|
|
|
2016-07-20 18:18:18 -04:00
|
|
|
- if right
|
2017-01-18 17:40:34 -05:00
|
|
|
- case right.type
|
|
|
|
- when 'match'
|
2016-07-21 14:44:12 -04:00
|
|
|
= diff_match_line nil, right.new_pos, text: left.text, view: :parallel
|
2017-03-13 16:09:43 -04:00
|
|
|
- when 'old-nonewline', 'new-nonewline'
|
2017-01-18 17:40:34 -05:00
|
|
|
%td.new_line.diff-line-num
|
2017-09-28 10:55:25 -04:00
|
|
|
%td.line_content.match.right-side= right.text
|
2014-09-12 12:43:44 -04:00
|
|
|
- else
|
2016-07-20 18:18:18 -04:00
|
|
|
- right_line_code = diff_file.line_code(right)
|
|
|
|
- right_position = diff_file.position(right)
|
2017-09-28 10:55:25 -04:00
|
|
|
%td.new_line.diff-line-num.js-avatar-container{ class: right.type, data: { linenumber: right.new_pos } }
|
2017-06-12 14:43:21 -04:00
|
|
|
= add_diff_note_button(right_line_code, right_position, 'new')
|
2017-01-22 19:07:41 -05:00
|
|
|
%a{ href: "##{right_line_code}", data: { linenumber: right.new_pos } }
|
2019-03-23 09:34:08 -04:00
|
|
|
%td.line_content.parallel.right-side{ id: right_line_code, class: right.type }= diff_line_content(right.rich_text)
|
2016-07-20 18:18:18 -04:00
|
|
|
- else
|
|
|
|
%td.old_line.diff-line-num.empty-cell
|
2017-09-28 10:55:25 -04:00
|
|
|
%td.line_content.parallel.right-side
|
2014-09-12 12:43:44 -04:00
|
|
|
|
2017-03-30 22:34:14 -04:00
|
|
|
- if discussions_left || discussions_right
|
|
|
|
= render "discussions/parallel_diff_discussion", discussions_left: discussions_left, discussions_right: discussions_right
|
2017-05-15 13:10:29 -04:00
|
|
|
- if !diff_file.new_file? && !diff_file.deleted_file? && diff_file.diff_lines.any?
|
2017-01-18 16:03:12 -05:00
|
|
|
- last_line = diff_file.diff_lines.last
|
2017-01-24 18:53:25 -05:00
|
|
|
- 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
|