sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 739fa98b38fbf1f779c041ada43e4c56484b1cd1
parent 026acf5e8e5e34d8ea732059144579c3c8b8b2c7
Author: Michael Stapelberg <michael@stapelberg.de>
Date:   Wed, 16 Jun 2010 20:08:30 +0200

Don’t display "..." after snippets which are displayed completely

Short mails (for example: "Yes, the date works for me.") often can
be displayed completely in the snippet. However, before this patch,
sup abbreviated the snippet even though it was not abbreviated.

Diffstat:
M lib/sup/message.rb | 2 ++
M lib/sup/modes/thread-index-mode.rb | 4 +---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
@@ -674,7 +674,9 @@ private
         @snippet ||= ""
         @snippet += " " unless @snippet.empty?
         @snippet += line.gsub(/^\s+/, "").gsub(/[\r\n]/, "").gsub(/\s+/, " ")
+        oldlen = @snippet.length
         @snippet = @snippet[0 ... SNIPPET_LEN].chomp
+        @snippet += "..." if @snippet.length < oldlen
         @dirty = true unless encrypted && $config[:discard_snippets_from_encrypted_messages]
         @snippet_contains_encrypted_content = true if encrypted
       end
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -876,8 +876,6 @@ protected
         :index_old_color
       end
 
-    snippet = t.snippet + (t.snippet.empty? ? "" : "...")
-
     size_padding = @size_widget_width - size_widget.display_length
     size_widget_text = sprintf "%#{size_padding}s%s", "", size_widget
 
@@ -898,7 +896,7 @@ protected
       (t.labels - @hidden_labels).map { |label| [:label_color, "#{label} "] } +
       [
       [subj_color, t.subj + (t.subj.empty? ? "" : " ")],
-      [:snippet_color, snippet],
+      [:snippet_color, t.snippet],
     ]
   end