summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-06-23 14:52:26 +0000
committerRobert Speicher <robert@gitlab.com>2016-06-23 14:52:26 +0000
commit110b2759c0c74d7bc85785ab481ff902cd7014d0 (patch)
tree0e8298d87df5c44cbfdcabc268e13087f8f7df89
parent9ee8693fdabc3368dde324d3d5db7a5122f1daba (diff)
parent9b49c466f2ad5f54de441160e625a874220aea28 (diff)
downloadgitlab-ce-110b2759c0c74d7bc85785ab481ff902cd7014d0.tar.gz
Merge branch 'fix-clickable-code-search-results' into 'master'
Fix clickable code search results Closes #17860 See merge request !4654
-rw-r--r--app/views/search/results/_blob.html.haml5
-rw-r--r--app/views/shared/_file_highlight.html.haml3
2 files changed, 5 insertions, 3 deletions
diff --git a/app/views/search/results/_blob.html.haml b/app/views/search/results/_blob.html.haml
index 0fe8a3b490a..290743feb4a 100644
--- a/app/views/search/results/_blob.html.haml
+++ b/app/views/search/results/_blob.html.haml
@@ -2,9 +2,10 @@
.blob-result
.file-holder
.file-title
- = link_to namespace_project_blob_path(@project.namespace, @project, tree_join(blob.ref, blob.filename), :anchor => "L" + blob.startline.to_s) do
+ - blob_link = namespace_project_blob_path(@project.namespace, @project, tree_join(blob.ref, blob.filename))
+ = link_to blob_link do
%i.fa.fa-file
%strong
= blob.filename
.file-content.code.term
- = render 'shared/file_highlight', blob: blob, first_line_number: blob.startline
+ = render 'shared/file_highlight', blob: blob, first_line_number: blob.startline, blob_link: blob_link
diff --git a/app/views/shared/_file_highlight.html.haml b/app/views/shared/_file_highlight.html.haml
index 37dcf39c062..ad944a19ca1 100644
--- a/app/views/shared/_file_highlight.html.haml
+++ b/app/views/shared/_file_highlight.html.haml
@@ -2,11 +2,12 @@
.line-numbers
- if blob.data.present?
- link_icon = icon('link')
+ - link = blob_link if defined?(blob_link)
- blob.data.each_line.each_with_index do |_, index|
- offset = defined?(first_line_number) ? first_line_number : 1
- i = index + offset
-# We're not using `link_to` because it is too slow once we get to thousands of lines.
- %a.diff-line-num{href: "#L#{i}", id: "L#{i}", 'data-line-number' => i}
+ %a.diff-line-num{href: "#{link}#L#{i}", id: "L#{i}", 'data-line-number' => i}
= link_icon
= i
.blob-content{data: {blob_id: blob.id}}