diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-03-11 20:23:29 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-03-11 20:23:29 +0000 |
commit | 21c79827ff73916aa7fa8a6cce0645fc34a7c7fd (patch) | |
tree | 0c85f6328ee655a5fe161e7037963656b1af1107 /app/views/common | |
parent | 099ba68836b9ff4544df3c46b6f5cb8a6081a185 (diff) | |
download | redmine-21c79827ff73916aa7fa8a6cce0645fc34a7c7fd.tar.gz redmine-21c79827ff73916aa7fa8a6cce0645fc34a7c7fd.zip |
Highlight changes inside diff lines (#7139).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5094 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/views/common')
-rw-r--r-- | app/views/common/_diff.rhtml | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/app/views/common/_diff.rhtml b/app/views/common/_diff.rhtml index 619790c13..03b06a0ce 100644 --- a/app/views/common/_diff.rhtml +++ b/app/views/common/_diff.rhtml @@ -1,66 +1,56 @@ <% diff = Redmine::UnifiedDiff.new(diff, :type => diff_type, :max_lines => Setting.diff_max_lines_displayed.to_i) -%> + <% diff.each do |table_file| -%> <div class="autoscroll"> -<% if diff_type == 'sbs' -%> +<% if diff.diff_type == 'sbs' -%> <table class="filecontent"> <thead> <tr><th colspan="4" class="filename"><%=to_utf8 table_file.file_name %></th></tr> </thead> <tbody> -<% prev_line_left, prev_line_right = nil, nil -%> -<% table_file.keys.sort.each do |key| -%> -<% if prev_line_left && prev_line_right && (table_file[key].nb_line_left != prev_line_left+1) && (table_file[key].nb_line_right != prev_line_right+1) -%> +<% table_file.each_line do |spacing, line| -%> +<% if spacing -%> <tr class="spacing"> -<th class="line-num">...</th><td></td><th class="line-num">...</th><td></td> + <th class="line-num">...</th><td></td><th class="line-num">...</th><td></td> +</tr> <% end -%> <tr> - <th class="line-num"><%= table_file[key].nb_line_left %></th> - <td class="line-code <%= table_file[key].type_diff_left %>"> - <pre><%=to_utf8 table_file[key].line_left %></pre> + <th class="line-num"><%= line.nb_line_left %></th> + <td class="line-code <%= line.type_diff_left %>"> + <pre><%=to_utf8 line.html_line_left %></pre> </td> - <th class="line-num"><%= table_file[key].nb_line_right %></th> - <td class="line-code <%= table_file[key].type_diff_right %>"> - <pre><%=to_utf8 table_file[key].line_right %></pre> + <th class="line-num"><%= line.nb_line_right %></th> + <td class="line-code <%= line.type_diff_right %>"> + <pre><%=to_utf8 line.html_line_right %></pre> </td> </tr> -<% prev_line_left, prev_line_right = table_file[key].nb_line_left.to_i, table_file[key].nb_line_right.to_i -%> <% end -%> </tbody> </table> <% else -%> -<table class="filecontent syntaxhl"> +<table class="filecontent"> <thead> <tr><th colspan="3" class="filename"><%=to_utf8 table_file.file_name %></th></tr> </thead> <tbody> -<% prev_line_left, prev_line_right = nil, nil -%> -<% table_file.keys.sort.each do |key, line| %> -<% if prev_line_left && prev_line_right && (table_file[key].nb_line_left != prev_line_left+1) && (table_file[key].nb_line_right != prev_line_right+1) -%> +<% table_file.each_line do |spacing, line| %> +<% if spacing -%> <tr class="spacing"> -<th class="line-num">...</th><th class="line-num">...</th><td></td> + <th class="line-num">...</th><th class="line-num">...</th><td></td> </tr> <% end -%> <tr> - <th class="line-num"><%= table_file[key].nb_line_left %></th> - <th class="line-num"><%= table_file[key].nb_line_right %></th> - <% if table_file[key].line_left.empty? -%> - <td class="line-code <%= table_file[key].type_diff_right %>"> - <pre><%=to_utf8 table_file[key].line_right %></pre> + <th class="line-num"><%= line.nb_line_left %></th> + <th class="line-num"><%= line.nb_line_right %></th> + <td class="line-code <%= line.type_diff %>"> + <pre><%=to_utf8 line.html_line %></pre> </td> - <% else -%> - <td class="line-code <%= table_file[key].type_diff_left %>"> - <pre><%=to_utf8 table_file[key].line_left %></pre> - </td> - <% end -%> </tr> -<% prev_line_left = table_file[key].nb_line_left.to_i if table_file[key].nb_line_left.to_i > 0 -%> -<% prev_line_right = table_file[key].nb_line_right.to_i if table_file[key].nb_line_right.to_i > 0 -%> <% end -%> </tbody> </table> <% end -%> - </div> <% end -%> |