diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-01-27 16:15:24 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-01-27 16:15:24 +0100 |
commit | 4be80f8aa3c585882b4499d6d69dcbf4a97eff29 (patch) | |
tree | 2bb212f39637ba5124897917d43650cda233b67c | |
parent | a93f7099fa2ed98746ebfb5e55322d0afb5068f8 (diff) | |
download | gitlab-ce-4be80f8aa3c585882b4499d6d69dcbf4a97eff29.tar.gz |
Fix highlighting in blame view.
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/projects/blame_controller.rb | 4 | ||||
-rw-r--r-- | app/views/projects/blame/show.html.haml | 6 |
3 files changed, 7 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG index 4b283f235a4..aebd6643e8b 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 9ea518e6c85..d2aee3879e9 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 53dcac78a9f..aecdec32d00 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} |