summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/search/_snippet_filter.html.haml2
-rw-r--r--lib/gitlab/snippet_search_results.rb14
2 files changed, 8 insertions, 8 deletions
diff --git a/app/views/search/_snippet_filter.html.haml b/app/views/search/_snippet_filter.html.haml
index 45155a77f1a..0d1984a0d78 100644
--- a/app/views/search/_snippet_filter.html.haml
+++ b/app/views/search/_snippet_filter.html.haml
@@ -2,7 +2,7 @@
%li{class: ("active" if @scope == 'snippet_blobs')}
= link_to search_filter_path(scope: 'snippet_blobs', snippets: true, group_id: nil, project_id: nil) do
%i.icon-code
- Code
+ Snippet Contents
.pull-right
= @search_results.snippet_blobs_count
%li{class: ("active" if @scope == 'snippet_titles')}
diff --git a/lib/gitlab/snippet_search_results.rb b/lib/gitlab/snippet_search_results.rb
index 4b406c30f47..04217aab49f 100644
--- a/lib/gitlab/snippet_search_results.rb
+++ b/lib/gitlab/snippet_search_results.rb
@@ -37,10 +37,10 @@ module Gitlab
end
def snippet_blobs
- matching_snippets = Snippet.where(id: limit_snippet_ids).search_code(query).order('updated_at DESC')
- matching_snippets = matching_snippets.to_a
+ search = Snippet.where(id: limit_snippet_ids).search_code(query)
+ search = search.order('updated_at DESC').to_a
snippets = []
- matching_snippets.each { |e| snippets << chunk_snippet(e) }
+ search.each { |e| snippets << chunk_snippet(e) }
snippets
end
@@ -58,14 +58,14 @@ module Gitlab
surrounding_lines = 3
used_lines = []
lined_content = snippet.content.split("\n")
- lined_content.each_with_index { |line, line_number|
+ lined_content.each_with_index do |line, line_number|
used_lines.concat bounded_line_numbers(
line_number,
0,
lined_content.size,
surrounding_lines
) if line.include?(query)
- }
+ end
used_lines = used_lines.uniq.sort
@@ -73,7 +73,7 @@ module Gitlab
snippet_chunks = []
snippet_start_line = 0
last_line = -1
- used_lines.each { |line_number|
+ used_lines.each do |line_number|
if last_line < 0
snippet_start_line = line_number
snippet_chunk << lined_content[line_number]
@@ -88,7 +88,7 @@ module Gitlab
snippet_start_line = line_number
end
last_line = line_number
- }
+ end
snippet_chunks << {
data: snippet_chunk.join("\n"),
start_line: snippet_start_line + 1