Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sort: avoid assertion under <attach-message>
Fixes: neomutt#2996 Commit b698a6a added an assert that tctx->tree was set and dropped an 'if', because I could not at the time find any scenario where we would try sorting threads but not find any. But in the meantime, I found (at least) one: when using <attach-message> and selecting the same folder as already being visited, and when no new mail has arrived in the meantime, then ALL messages already have e->thread set, and there is no need to sort subthreads. But the comment behind the assert was correct: in that code path, we forgot to restore the value of $sort after temporarily munging it to the value of $sort_aux; and this latent problem can be observed even in the 20210205 release (I did not research to find when it was first introduced). Later, commit aaa2ece changed things so that we no longer munge $sort in the first place. So now all we need to do is remove the bogus assertion, while still restoring the 'if' to avoid unnecessary work if there are no new threads that need subthread sorting. Note that the issue of potentially leaving $sort munged to $sort_aux if ctx->tree remains unset after searching for new threads is present even in upstream mutt. But upstream never saw the problem with <attach-message> because it always opened a NEW mailbox context, passing init=true. It is only in neomutt (and possibly only with notmuch folders, since I didn't manage to reproduce with maildir), where we try harder to reuse an existing mailbox and pass init=false while tctx->tree is still NULL.
- Loading branch information