diff options
Diffstat (limited to 'app/views/shared/_file_highlight.html.haml')
-rw-r--r-- | app/views/shared/_file_highlight.html.haml | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/app/views/shared/_file_highlight.html.haml b/app/views/shared/_file_highlight.html.haml index 73ace033dc6..a749d1037a1 100644 --- a/app/views/shared/_file_highlight.html.haml +++ b/app/views/shared/_file_highlight.html.haml @@ -1,16 +1,28 @@ +-# We're not using `link_to` in the line loop because it is too slow once we get to thousands of lines. + +- offset = defined?(first_line_number) ? first_line_number : 1 +- highlight = defined?(highlight_line) && highlight_line ? highlight_line - offset : nil +- file_line_blame = Feature.enabled?(:file_line_blame) + +- if file_line_blame + - line_class = "js-line-links" + - blame_path = project_blame_path(@project, tree_join(@ref, blob.path)) +- else + - line_class = nil + - blame_path = nil + +- highlighted_blob = blob.present.highlight + #blob-content.file-content.code.js-syntax-highlight - - offset = defined?(first_line_number) ? first_line_number : 1 - - if Feature.enabled?(:file_line_blame) - - blame_path = project_blame_path(@project, tree_join(@ref, blob.path)) .line-numbers{ class: "gl-px-0!", data: { blame_path: blame_path } } - if blob.data.present? - - blob.data.each_line.each_with_index do |_, index| + - highlighted_blob.lines.count.times do |index| - i = index + offset - -# We're not using `link_to` because it is too slow once we get to thousands of lines. - %a.file-line-num.diff-line-num{ class: ("js-line-links" if Feature.enabled?(:file_line_blame)), href: "#L#{i}", id: "L#{i}", 'data-line-number' => i } + + %a.file-line-num.diff-line-num{ class: line_class, href: "#L#{i}", id: "L#{i}", 'data-line-number' => i } = i - - highlight = defined?(highlight_line) && highlight_line ? highlight_line - offset : nil + .blob-content{ data: { blob_id: blob.id, path: blob.path, highlight_line: highlight, qa_selector: 'file_content' } } %pre.code.highlight %code - = blob.present.highlight + = highlighted_blob |