diff --git a/CHANGELOG b/CHANGELOG index 4b283f235a4d7ef54096bdc53fc05e9df3b46d8d..aebd6643e8b58cd5b37cbba9a9ce2d387c0f00c2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ v 8.4.2 (unreleased) improvement when checking if a repository was empty - Add instrumentation for Gitlab::Git::Repository instance methods so we can track them in Performance Monitoring. + - Fix highlighting in blame view. v 8.4.2 (unreleased) - Fix method undefined when using external commit status in builds diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb index 9ea518e6c857f8681e6fb6a6bd20ca6ef07abd20..d2aee3879e9821c51c1d2ac1ae35cb4311e40ca6 100644 --- a/app/controllers/projects/blame_controller.rb +++ b/app/controllers/projects/blame_controller.rb @@ -18,7 +18,10 @@ class Projects::BlameController < Projects::ApplicationController groups = [] current_group = nil + highlighted_lines = Gitlab::Highlight.highlight(@blob.name, @blob.data).lines + i = 0 blame.each do |commit, line| + line = highlighted_lines[i].html_safe if prev_sha && prev_sha == commit.sha current_group[:lines] << line else @@ -27,6 +30,7 @@ class Projects::BlameController < Projects::ApplicationController end prev_sha = commit.sha + i += 1 end groups << current_group if current_group.present? diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml index 53dcac78a9f9e1c7da6177aee9bb7b0ba1dbf1ac..aecdec32d00b7f16765a5c00e250efd67490badd 100644 --- a/app/views/projects/blame/show.html.haml +++ b/app/views/projects/blame/show.html.haml @@ -15,7 +15,6 @@ .file-content.blame.code.js-syntax-highlight %table - current_line = 1 - - blame_highlighter = highlighter(@blob.name, @blob.data, nowrap: true) - @blame.each do |blame_group| %tr %td.blame-commit @@ -38,8 +37,7 @@ \ - current_line += line_count %td.lines - %pre{class: 'code highlight'} + %pre.code.highlight %code - blame_group[:lines].each do |line| - :preserve - #{blame_highlighter.highlight(line)} + #{line}