]> git.notmuchmail.org Git - sup/commitdiff
attachment tweaks
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 6 Jul 2007 14:44:49 +0000 (14:44 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Fri, 6 Jul 2007 14:44:49 +0000 (14:44 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@474 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/modes/edit-message-mode.rb

index 5285279dc4ac7c2860c69f243f8cc73a07d6b493..f0e4afbdc6a98cb7739e188ee31017e0a21e7bd4 100644 (file)
@@ -72,7 +72,7 @@ class EditMessageMode < LineCursorMode
   end
 
   def delete_attachment
-    i = curpos - @top_lines
+    i = curpos - @attachment_lines_offset
     if i >= 0 && i < @attachments.size && BufferManager.ask_yes_or_no("Delete attachment #{@attachments[i]}?")
       @attachments.delete_at i
       update
@@ -88,10 +88,14 @@ protected
 
   def regen_text
     top = header_lines(@header - NON_EDITABLE_HEADERS) + [""]
-    @text = top + @body + 
-      @attachments.map { |f| [[:attachment_color, "+ Attachment: #{f} (#{f.human_size})"]] }
-    @top_lines = top.size
+    @text = top + @body
     @text += sig_lines unless $config[:edit_signature]
+
+    unless @attachments.empty?
+      @text += [""]
+      @attachment_lines_offset = @text.length
+      @text += @attachments.map { |f| [[:attachment_color, "+ Attachment: #{f} (#{f.human_size})"]] }
+    end
   end
 
   def parse_file fn