Commit fcc42e80 authored by Miguel Rincon's avatar Miguel Rincon

Merge branch 'line-speed' into 'master'

Improve line rendering speed [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!57237
parents afbdc165 51570c70
......@@ -48,7 +48,7 @@ module NotesHelper
data[:note_type] = LegacyDiffNote.name
else
data[:note_type] = DiffNote.name
data[:position] = position.to_json
data[:position] = Gitlab::Json.dump(position)
end
data
......
......@@ -26,12 +26,10 @@
= stylesheet_link_tag 'mailers/highlighted_diff_email'
%table
= render partial: "projects/diffs/line",
= render partial: "projects/diffs/email_line",
collection: discussion.truncated_diff_lines(diff_limit: diff_limit),
as: :line,
locals: { diff_file: discussion.diff_file,
plain: true,
email: true }
locals: { diff_file: discussion.diff_file }
%div{ style: note_style }
= markdown(note.note, pipeline: :email, author: note.author, current_user: @recipient, issuable_reference_expansion_enabled: true)
......@@ -74,7 +74,7 @@
- blob = diff_file.blob
- if blob && blob.readable_text?
%table.code.white
= render partial: "projects/diffs/line", collection: diff_file.highlighted_diff_lines, as: :line, locals: { diff_file: diff_file, plain: true, email: true }
= render partial: "projects/diffs/email_line", collection: diff_file.highlighted_diff_lines, as: :line, locals: { diff_file: diff_file }
- else
No preview for this file type
%br
-# This template is used when rendering diffs in email notifications
-# Called inside: app/views/notify/repository_push_email.html.haml
-# app/views/notify/_note_email.html.haml
%tr.line_holder{ class: line.type }
- case line.type
- when 'match'
= diff_match_line line.old_pos, line.new_pos, text: line.text
- when 'old-nonewline', 'new-nonewline'
%td.old_line.diff-line-num
%td.new_line.diff-line-num
%td.line_content.match= line.text
- else
%td.old_line.diff-line-num{ class: line.type, data: { linenumber: line.old_pos } }
= diff_link_number(line.type, "new", line.old_pos)
%td.new_line.diff-line-num{ class: line.type, data: { linenumber: line.new_pos } }
= diff_link_number(line.type, "old", line.new_pos)
%td.line_content{ class: line.type }<
%pre= line.rich_text
-# This file is deprecated in favour of inline rendering:
-# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57237
- plain = local_assigns.fetch(:plain, false)
- discussions = local_assigns.fetch(:discussions, nil)
- line_code = diff_file.line_code(line)
......
......@@ -4,6 +4,34 @@
%a.show-suppressed-diff.cursor-pointer.js-show-suppressed-diff= _("Changes suppressed. Click to show.")
%table.text-file.diff-wrap-lines.code.code-commit.js-syntax-highlight.commit-diff{ data: diff_view_data, class: too_big ? 'hide' : '' }
- if Feature.enabled?(:inline_haml_diff_line_rendering, @project, default_enabled: :yaml)
- diff_file.highlighted_diff_lines.each do |line|
- line_code = diff_file.line_code(line)
%tr.line_holder{ class: line.type, id: line_code }
- case line.type
- when 'match'
= diff_match_line line.old_pos, line.new_pos, text: line.text
- when 'old-nonewline', 'new-nonewline'
%td.old_line.diff-line-num
%td.new_line.diff-line-num
%td.line_content.match= line.text
- else
%td.old_line.diff-line-num{ class: "#{line.type} js-avatar-container", data: { linenumber: line.old_pos } }
= add_diff_note_button(line_code, diff_file.position(line), line.type)
%a{ href: "##{line_code}", data: { linenumber: diff_link_number(line.type, "new", line.old_pos) } }
%td.new_line.diff-line-num{ class: line.type, data: { linenumber: line.new_pos } }
%a{ href: "##{line_code}", data: { linenumber: diff_link_number(line.type, "old", line.new_pos) } }
%td.line_content{ class: line.type }<
= diff_line_content(line.rich_text)
- if line.discussable? && @grouped_diff_discussions.present? && @grouped_diff_discussions[line_code]
- line_discussions = @grouped_diff_discussions[line_code]
= render "discussions/diff_discussion", discussions: line_discussions, expanded: line_discussions.any?(&:expanded?)
- else
= render partial: "projects/diffs/line",
collection: diff_file.highlighted_diff_lines,
as: :line,
......
---
name: inline_haml_diff_line_rendering
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57237
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/330582
milestone: '14.7'
type: development
group: group::source code
default_enabled: false
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