From 69d6b58f88d1cd2d149b75398f2f727b6cc70a33 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 3 Nov 2013 22:01:25 +0900 Subject: [PATCH] Do not block on --no-sort --- fzf | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/fzf b/fzf index 8516900..9ef0fe7 100755 --- a/fzf +++ b/fzf @@ -180,7 +180,7 @@ def print_input end end -def print_info progress = true, msg = nil +def print_info msg = nil @fan ||= '-\|/-\|/'.split(//) C.setpos cursor_y - 1, 0 C.clrtoeol @@ -193,8 +193,7 @@ def print_info progress = true, msg = nil ' ' end C.attron color(:info, false) do - progress &&= "#{prefix}#{@matches.length}/#{@count}" - C.addstr progress if progress + C.addstr "#{prefix}#{@matches.length}/#{@count}" C.addstr msg if msg end end @@ -337,11 +336,9 @@ searcher = Thread.new { begin while true - wait_for_completion = nil @mtx.synchronize do while true events.merge! @events - wait_for_completion = !@sort && !events[:loaded] if @events.empty? # No new events @cv.wait @mtx @@ -351,7 +348,7 @@ searcher = Thread.new { break end - if !wait_for_completion && events[:new] + if events[:new] @lists << [@new, {}] @count += @new.length @new = [] @@ -359,15 +356,6 @@ searcher = Thread.new { end end#mtx - if wait_for_completion - @smtx.synchronize do - print_info false, " +#{@new.length}" - refresh - end - sleep((delay = [20, delay + 5].min) * 0.01) - next - end - new_search = events[:key] || events[:new] user_input = events[:key] || events[:vcursor] progress = 0 @@ -403,7 +391,7 @@ searcher = Thread.new { found.concat(cache[q] ||= q.empty? ? list : begin if progress < 100 && Time.now - started_at > 0.5 @smtx.synchronize do - print_info true, " (#{progress}%)" + print_info " (#{progress}%)" refresh end end