From: Mike Stipicevic Date: Mon, 16 Feb 2009 05:03:57 +0000 (-0500) Subject: Added undo for starring X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=5154ac52b12329bee5b57e5abd9180e21c1c9303;p=sup Added undo for starring --- diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb index 120acad..62fdb85 100644 --- a/lib/sup/modes/thread-index-mode.rb +++ b/lib/sup/modes/thread-index-mode.rb @@ -237,24 +237,41 @@ EOS end def actually_toggle_starred t + thread = t # cargo cult programming + pos = curpos if t.has_label? :starred # if ANY message has a star + undo = lambda { + thread.first.add_label :starred + update_text_for_line pos + UpdateManager.relay self, :starred, thread.first + } t.remove_label :starred # remove from all UpdateManager.relay self, :unstarred, t.first else + undo = lambda { + thread.remove_label :starred + update_text_for_line pos + UpdateManager.relay self, :unstarred, thread.first + } t.first.add_label :starred # add only to first UpdateManager.relay self, :starred, t.first end + + return undo end def toggle_starred t = cursor_thread or return - actually_toggle_starred t + undo = actually_toggle_starred t + UndoManager.register("starring/unstarring thread #{t.first.id}",undo) update_text_for_line curpos cursor_down end def multi_toggle_starred threads - threads.each { |t| actually_toggle_starred t } + undo = threads.map { |t| actually_toggle_starred t } + UndoManager.register("starring/unstarring #{threads.size} #{threads.size.pluralize 'thread'}", + undo) regen_text end