sync with 0.7.6cvs15
[claws.git] / src / news.c
index 507a6b14ab7b25e8754546160c44d0d4535e0fb7..68dcf6226e422c4456137b0c94b785e7a0c6d347 100644 (file)
@@ -392,16 +392,27 @@ gint news_scan_group(Folder *folder, FolderItem *item)
        }
        g_free(path);
 
-       if (first < min) {
+       if (max < first || last < min)
                new = unread = total = num;
-       } else if (max < first) {
-               new = unread = total = num;
-       } else if (last > max) {
-               new += last - max;
-               unread += last - max;
+       else {
+               if (min < first)
+                       min = first;
+               else if (first < min) {
+                       num -= min - first;
+                       first = min;
+               }
+
+               if (last < max)
+                       max = last;
+               else if (max < last) {
+                       new += last - max;
+                       unread += last - max;
+               }
+
                if (new > num) new = num;
                if (unread > num) unread = num;
        }
+
        item->new = new;
        item->unread = unread;
        item->total = num;