Fix error on Rubinius

This commit is contained in:
Junegunn Choi 2013-12-26 01:43:20 +09:00
parent bff7e9edf5
commit 39eb85596c

33
fzf
View File

@ -556,26 +556,25 @@ class FZF
if new_search && !lists.empty? if new_search && !lists.empty?
q, cx = events.delete(:key) || [q, 0] q, cx = events.delete(:key) || [q, 0]
empty = matcher.empty?(q) empty = matcher.empty?(q)
matches = fcache[q] ||= unless matches = fcache[q]
begin found = []
found = [] skip = false
skip = false cnt = 0
cnt = 0 lists.each do |list|
lists.each do |list| cnt += list.length
cnt += list.length skip = @mtx.synchronize { @events[:key] }
skip = @mtx.synchronize { @events[:key] } break if skip
break if skip
if !empty && (progress = 100 * cnt / @count.get) < 100 && Time.now - started_at > 0.5 if !empty && (progress = 100 * cnt / @count.get) < 100 && Time.now - started_at > 0.5
render { print_info " (#{progress}%)" } render { print_info " (#{progress}%)" }
end
found.concat(q.empty? ? list :
matcher.match(list, q, q[0, cx], q[cx..-1]))
end end
next if skip
@sort ? found : found.reverse found.concat(q.empty? ? list :
matcher.match(list, q, q[0, cx], q[cx..-1]))
end end
next if skip
matches = fcache[q] = @sort ? found : found.reverse
end
if !empty && @sort && matches.length <= @sort if !empty && @sort && matches.length <= @sort
matches = sort_by_rank(matches) matches = sort_by_rank(matches)