about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-10-01 18:45:03 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-10-01 18:45:03 +0200
commit275771bef2ecfe26390b8b6f0eb0c08ba51a8a85 (patch)
tree571b070b304d75b312a1cabc421e42e3884efebc
parent54988a45971a2f0b2a4b77515546487f5235209b (diff)
downloadnotyet-275771bef2ecfe26390b8b6f0eb0c08ba51a8a85.tar.gz
notyet-275771bef2ecfe26390b8b6f0eb0c08ba51a8a85.tar.xz
notyet-275771bef2ecfe26390b8b6f0eb0c08ba51a8a85.zip
only count leaf tasks
-rwxr-xr-xnotyet15
1 files changed, 4 insertions, 11 deletions
diff --git a/notyet b/notyet
index 8ec739b..ce2366f 100755
--- a/notyet
+++ b/notyet
@@ -33,18 +33,11 @@ class Entry < Struct.new(:depth, :state, :desc, :file, :line, :children)
   end
 
   def count(s=nil)
-    n = 0
-    if s.nil? || s.index(state)
-      n += 1
-    end
-
-    if desc =~ /^#(include|exec)\s/ || depth < 0
-      n -= 1  if n > 0
+    if children.empty? && (s.nil? || s.index(state))
+      return 1
+    else
+      children.map { |c| c.count(s) }.sum
     end
-
-    children.each { |c| n += c.count(s) }
-
-    n
   end
 
   def sort