X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fquery.cc;h=381529b538c270695144d4aef8ae7ba673dee996;hp=1777e47dc044daa339c7ec0988e3d0fbef3de5a9;hb=bbf4b8e4aec69b5684587b77bd0af743afd61eb1;hpb=93dcc3b695e19dd36cc8f638c6e01ecbbd9a447d diff --git a/lib/query.cc b/lib/query.cc index 1777e47d..381529b5 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -200,7 +200,7 @@ notmuch_query_search_threads (notmuch_query_t *query, seen = g_hash_table_new_full (g_str_hash, g_str_equal, free, NULL); - while (threads_seen < first + max_threads) + while (max_threads < 0 || threads_seen < first + max_threads) { int messages_seen_previously = messages_seen; @@ -218,7 +218,7 @@ notmuch_query_search_threads (notmuch_query_t *query, thread_id, NULL, (void **) &thread)) { - if (threads_seen > first) { + if (threads_seen >= first) { thread = _notmuch_thread_create (query, query->notmuch, thread_id); g_ptr_array_add (threads->threads, thread); @@ -237,6 +237,9 @@ notmuch_query_search_threads (notmuch_query_t *query, notmuch_message_destroy (message); messages_seen++; + + if (max_threads >= 0 && threads_seen >= first + max_threads) + break; } /* Stop if we're not seeing any more messages. */