diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-09-28 16:55:25 +0200 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-10-02 18:39:25 +0200 |
commit | b74c643c66fd15c95ad148231ebcf4f85283ca16 (patch) | |
tree | 889376c02f90b53b2bfe581dbef3896a3b6e4261 /app/helpers/diff_helper.rb | |
parent | e0e49f2f7120fee6ee34236ed6463e4c130f2ad1 (diff) | |
download | gitlab-ce-b74c643c66fd15c95ad148231ebcf4f85283ca16.tar.gz |
Only copy old/new code when selecting left/right side of parallel diffdm-copy-parallel-diff
Diffstat (limited to 'app/helpers/diff_helper.rb')
-rw-r--r-- | app/helpers/diff_helper.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 28f591a4e22..4e4a66e8a02 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -33,19 +33,21 @@ module DiffHelper end def diff_match_line(old_pos, new_pos, text: '', view: :inline, bottom: false) - content = content_tag :td, text, class: "line_content match #{view == :inline ? '' : view}" - cls = ['diff-line-num', 'unfold', 'js-unfold'] - cls << 'js-unfold-bottom' if bottom + content_line_class = %w[line_content match] + content_line_class << 'parallel' if view == :parallel + + line_num_class = %w[diff-line-num unfold js-unfold] + line_num_class << 'js-unfold-bottom' if bottom html = '' if old_pos - html << content_tag(:td, '...', class: cls + ['old_line'], data: { linenumber: old_pos }) - html << content unless view == :inline + html << content_tag(:td, '...', class: [*line_num_class, 'old_line'], data: { linenumber: old_pos }) + html << content_tag(:td, text, class: [*content_line_class, 'left-side']) if view == :parallel end if new_pos - html << content_tag(:td, '...', class: cls + ['new_line'], data: { linenumber: new_pos }) - html << content + html << content_tag(:td, '...', class: [*line_num_class, 'new_line'], data: { linenumber: new_pos }) + html << content_tag(:td, text, class: [*content_line_class, ('right-side' if view == :parallel)]) end html.html_safe |