sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit a6ba8231b67f424e302d9d70d9b9ed69f6678ee6
parent 275f9e46252e8713d59101f77a36cc86d2fcb866
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Thu, 10 Jan 2008 09:44:16 -0800

Merge branch 'master' into next

Diffstat:
M lib/sup/buffer.rb | 2 +-
M lib/sup/thread.rb | 21 +++++++++++----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -63,7 +63,6 @@ class Buffer
     @title = opts[:title] || ""
     @force_to_top = opts[:force_to_top] || false
     @x, @y, @width, @height = 0, 0, width, height
-    @in_x = ENV["TERM"] =~ /(xterm|rxvt|screen)/
   end
 
   def content_height; @height - 1; end
@@ -178,6 +177,7 @@ EOS
     @textfields = {}
     @flash = nil
     @shelled = @asking = false
+    @in_x = ENV["TERM"] =~ /(xterm|rxvt|screen)/
 
     self.class.i_am_the_instance self
   end
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
@@ -289,7 +289,10 @@ class ThreadSet
     remove_container c
     p.children << c
     c.parent = p
-    update_threading_for c
+
+    ## if the child was previously a top-level container, it now ain't,
+    ## so ditch our thread and kill it if necessary
+    prune_thread_of c
   end
   private :link
 
@@ -298,20 +301,18 @@ class ThreadSet
   end
   private :remove_container
 
-  def update_threading_for c
-    ## if the child was previously a top-level container, but now is not,
-    ## ditch our thread and kill it if necessary
-    if c.thread && !c.root?
-      c.thread.drop c
-      @threads.delete_if { |k, v| v == c.thread } if c.thread.empty?
-      c.thread = nil
-    end
+  def prune_thread_of c
+    return unless c.thread
+    c.thread.drop c
+    @threads.delete_if { |k, v| v == c.thread } if c.thread.empty?
+    c.thread = nil
   end
-  private :update_threading_for
+  private :prune_thread_of
 
   def remove_id mid
     return unless(c = @messages[mid])
     remove_container c
+    prune_thread_of c
   end
 
   def remove_thread_containing_id mid