Sort within FuzzyFileFinder (optionally) rather than outside
This commit is contained in:
parent
4ccc3c1fd5
commit
69c5b3a3fe
|
@ -304,13 +304,14 @@ module Diakonos
|
|||
directories: @session.dir,
|
||||
ceiling: @settings['fuzzy_file_find.max_files'] || 8192,
|
||||
ignores: @fuzzy_ignores,
|
||||
recursive: @settings['fuzzy_file_find.recursive']
|
||||
recursive: @settings['fuzzy_file_find.recursive'],
|
||||
sorted: true
|
||||
)
|
||||
|
||||
finder_block = lambda { |input|
|
||||
break if input =~ %r{^/}
|
||||
|
||||
matches = finder.find(input).sort_by { |m| m[:path] }
|
||||
matches = finder.find(input)
|
||||
with_list_file do |list|
|
||||
list.puts matches.map { |m| m[:path] }
|
||||
end
|
||||
|
|
9
lib/diakonos/vendor/fuzzy_file_finder.rb
vendored
9
lib/diakonos/vendor/fuzzy_file_finder.rb
vendored
|
@ -125,6 +125,7 @@ class FuzzyFileFinder
|
|||
@roots = root_dirnames.map { |d| Directory.new(d, true) }
|
||||
@shared_prefix = determine_shared_prefix
|
||||
@shared_prefix_re = Regexp.new("^#{Regexp.escape(shared_prefix)}" + (shared_prefix.empty? ? "" : "/"))
|
||||
@sorted = params[:sorted]
|
||||
|
||||
@files = []
|
||||
@directories = {} # To detect link cycles
|
||||
|
@ -202,11 +203,17 @@ class FuzzyFileFinder
|
|||
# Array. If +max+ is nil, all matches will be returned.
|
||||
def find(pattern, max=nil)
|
||||
results = []
|
||||
|
||||
search(pattern) do |match|
|
||||
results << match
|
||||
break if max && results.length >= max
|
||||
end
|
||||
return results
|
||||
|
||||
if @sorted
|
||||
results.sort_by { |m| m[:path] }
|
||||
else
|
||||
results
|
||||
end
|
||||
end
|
||||
|
||||
# Displays the finder object in a sane, non-explosive manner.
|
||||
|
|
Loading…
Reference in a new issue