Commit 4be80f8a authored by Douwe Maan's avatar Douwe Maan

Fix highlighting in blame view.

parent a93f7099
...@@ -20,6 +20,7 @@ v 8.4.2 (unreleased) ...@@ -20,6 +20,7 @@ v 8.4.2 (unreleased)
improvement when checking if a repository was empty improvement when checking if a repository was empty
- Add instrumentation for Gitlab::Git::Repository instance methods so we can - Add instrumentation for Gitlab::Git::Repository instance methods so we can
track them in Performance Monitoring. track them in Performance Monitoring.
- Fix highlighting in blame view.
v 8.4.2 (unreleased) v 8.4.2 (unreleased)
- Fix method undefined when using external commit status in builds - Fix method undefined when using external commit status in builds
......
...@@ -18,7 +18,10 @@ class Projects::BlameController < Projects::ApplicationController ...@@ -18,7 +18,10 @@ class Projects::BlameController < Projects::ApplicationController
groups = [] groups = []
current_group = nil current_group = nil
highlighted_lines = Gitlab::Highlight.highlight(@blob.name, @blob.data).lines
i = 0
blame.each do |commit, line| blame.each do |commit, line|
line = highlighted_lines[i].html_safe
if prev_sha && prev_sha == commit.sha if prev_sha && prev_sha == commit.sha
current_group[:lines] << line current_group[:lines] << line
else else
...@@ -27,6 +30,7 @@ class Projects::BlameController < Projects::ApplicationController ...@@ -27,6 +30,7 @@ class Projects::BlameController < Projects::ApplicationController
end end
prev_sha = commit.sha prev_sha = commit.sha
i += 1
end end
groups << current_group if current_group.present? groups << current_group if current_group.present?
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
.file-content.blame.code.js-syntax-highlight .file-content.blame.code.js-syntax-highlight
%table %table
- current_line = 1 - current_line = 1
- blame_highlighter = highlighter(@blob.name, @blob.data, nowrap: true)
- @blame.each do |blame_group| - @blame.each do |blame_group|
%tr %tr
%td.blame-commit %td.blame-commit
...@@ -38,8 +37,7 @@ ...@@ -38,8 +37,7 @@
\ \
- current_line += line_count - current_line += line_count
%td.lines %td.lines
%pre{class: 'code highlight'} %pre.code.highlight
%code %code
- blame_group[:lines].each do |line| - blame_group[:lines].each do |line|
:preserve #{line}
#{blame_highlighter.highlight(line)}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment