diff mcabber/mcabber/hbuf.c @ 1965:ec737f5f1d6f

Couple of readmark-related bugfixes
author Mikael Berthe <mikael@lilotux.net>
date Fri, 18 Mar 2011 12:29:57 +0100
parents 39021fd6b0e1
children 88dafee4ee49
line wrap: on
line diff
--- a/mcabber/mcabber/hbuf.c	Tue Mar 15 14:14:20 2011 +0100
+++ b/mcabber/mcabber/hbuf.c	Fri Mar 18 12:29:57 2011 +0100
@@ -347,7 +347,10 @@
       (*array_elt)->mucnicklen = blk->prefix.mucnicklen;
       (*array_elt)->text       = g_strndup(blk->ptr, maxlen);
 
-      if ((blk->flags & HBB_FLAG_PERSISTENT) && blk->prefix.flags) {
+      if ((blk->flags & HBB_FLAG_PERSISTENT) &&
+          (blk->prefix.flags & ~HBB_PREFIX_READMARK)) {
+        // This is a new message: persistent block flag and no prefix flag
+        // (except a possible readmark flag)
         last_persist_prefixflags = blk->prefix.flags;
       } else {
         // Propagate highlighting flags
@@ -532,12 +535,13 @@
 
   if (!hbuf) return;
 
-  hbuf = g_list_last(hbuf);
+  hbuf = hbuf_previous_persistent(g_list_last(hbuf));
 
   if (action) {
     // Add a readmark flag
     blk = (hbuf_block*)(hbuf->data);
-    blk->prefix.flags ^= HBB_PREFIX_READMARK;
+    blk->prefix.flags |= HBB_PREFIX_READMARK;
+
     // Shift hbuf in order to remove previous flags
     // (maybe it can be optimized out, if there's no risk
     //  we have several marks)