about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-10-29 22:49:08 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-10-29 22:49:08 +0100
commit20d921bff24f45de6872a498f1fcfd3cec27f6ab (patch)
treec1de19eb9829b8e85e658456d069d4f287704ae8
parent1b1ac6dcc0f8de302781c8ebcc57eb9235238f62 (diff)
downloadnotyet-20d921bff24f45de6872a498f1fcfd3cec27f6ab.tar.gz
notyet-20d921bff24f45de6872a498f1fcfd3cec27f6ab.tar.xz
notyet-20d921bff24f45de6872a498f1fcfd3cec27f6ab.zip
compute stats before filtering
-rwxr-xr-xnotyet10
1 files changed, 8 insertions, 2 deletions
diff --git a/notyet b/notyet
index 5d1633a..d4e643a 100755
--- a/notyet
+++ b/notyet
@@ -24,9 +24,9 @@ class Entry < Struct.new(:depth, :state, :desc, :file, :line, :children)
     end
 
     if depth < 0
-      puts "#{desc.strip} [#{count("xX")}/#{count("-xX")}]".lstrip  unless $edit
+      puts "#{desc.strip} [#{stat}]".lstrip  unless $edit
     else
-      stat = children.empty? ? "" : " [#{count("xX")}/#{count("-xX")}]"
+      stat = children.empty? ? "" : " [#{self.stat}]"
       print "#{file}:#{line}\t"  if $edit && depth >= 0
       print "#{" " * depth}#{state} #{desc}#{stat}\n"  if depth >= 0
     end
@@ -34,6 +34,11 @@ class Entry < Struct.new(:depth, :state, :desc, :file, :line, :children)
     children.each { |c| c.dump }
   end
 
+  def stat
+    children.each { |c| c.stat }
+    @stat ||= "#{count("xX")}/#{count("-xX")}"
+  end
+
   def count(s=nil)
     if children.empty? && (s.nil? || s.index(state))
       return 1
@@ -219,6 +224,7 @@ files.each { |file|
 t.splat
 t.propagate
 t.sort
+t.stat
 t.filter(ARGV)
 
 if count_only