Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Bajao <ebajao@gitlab.com>2019-08-09 03:13:09 +0300
committerPatrick Bajao <ebajao@gitlab.com>2019-08-09 03:13:09 +0300
commit6d318af5f95cc4091b09f1b2f8ed9981f3a8b9c7 (patch)
tree34ad57d297cc184075fb8c808eac3275266e8f3a /app/presenters/blobs
parent00223f91f316a0d09b158595990cf1cd237c27ec (diff)
Revert "Merge branch '65152-selective-highlight' into 'master'"
This reverts merge request !31361
Diffstat (limited to 'app/presenters/blobs')
-rw-r--r--app/presenters/blobs/unfold_presenter.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/app/presenters/blobs/unfold_presenter.rb b/app/presenters/blobs/unfold_presenter.rb
index f4672d22fc9..21a1e1309e0 100644
--- a/app/presenters/blobs/unfold_presenter.rb
+++ b/app/presenters/blobs/unfold_presenter.rb
@@ -21,19 +21,20 @@ module Blobs
load_all_blob_data
@subject = blob
+ @all_lines = blob.data.lines
super(params)
if full?
- self.attributes = { since: 1, to: all_lines.size, bottom: false, unfold: false, offset: 0, indent: 0 }
+ self.attributes = { since: 1, to: @all_lines.size, bottom: false, unfold: false, offset: 0, indent: 0 }
end
end
# Returns an array of Gitlab::Diff::Line with match line added
def diff_lines
- diff_lines = limited_blob_lines(since, to).map.with_index do |line, index|
- full_line = line.delete("\n")
+ diff_lines = lines.map.with_index do |line, index|
+ full_line = limited_blob_lines[index].delete("\n")
- Gitlab::Diff::Line.new(full_line, nil, nil, nil, nil, rich_text: lines[index])
+ Gitlab::Diff::Line.new(full_line, nil, nil, nil, nil, rich_text: line)
end
add_match_line(diff_lines)
@@ -42,7 +43,7 @@ module Blobs
end
def lines
- @lines ||= highlight(since: since, to: to).lines.map(&:html_safe)
+ @lines ||= limit(highlight.lines).map(&:html_safe)
end
def match_line_text
@@ -58,7 +59,7 @@ module Blobs
def add_match_line(diff_lines)
return unless unfold?
- if bottom? && to < all_lines.size
+ if bottom? && to < @all_lines.size
old_pos = to - offset
new_pos = to
elsif since != 1
@@ -72,5 +73,15 @@ module Blobs
bottom? ? diff_lines.push(match_line) : diff_lines.unshift(match_line)
end
+
+ def limited_blob_lines
+ @limited_blob_lines ||= limit(@all_lines)
+ end
+
+ def limit(lines)
+ return lines if full?
+
+ lines[since - 1..to - 1]
+ end
end
end