From 20d921bff24f45de6872a498f1fcfd3cec27f6ab Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 29 Oct 2017 22:49:08 +0100 Subject: compute stats before filtering --- notyet | 10 ++++++++-- 1 file 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 -- cgit 1.4.1