From ea1851e00d4814b1de3eb992e53848fb17f9f473 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 2 Jan 2013 19:32:32 +0100 Subject: [PATCH] Iterate over the messages from the end, not from the start (the corrected message is way more likely to be recent) --- src/text_buffer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/text_buffer.py b/src/text_buffer.py index f1c4eb24..85ccd011 100644 --- a/src/text_buffer.py +++ b/src/text_buffer.py @@ -77,7 +77,8 @@ class TextBuffer(object): return ret_val or 1 def modify_message(self, txt, old_id, new_id, highlight=False, time=None): - for i, msg in enumerate(self.messages): + for i in range(len(self.messages) -1, -1, -1): + msg = self.messages[i] if msg.identifier == old_id: message = self.make_message(txt, time if time else msg.time, msg.nickname, msg.nick_color, None, msg.user, new_id, highlight=highlight, old_message=msg, revisions=msg.revisions + 1) self.messages[i] = message