Index: evolution-data-server/camel/camel-vee-folder.c
===================================================================
--- evolution-data-server/camel/camel-vee-folder.c	(revision 9778)
+++ evolution-data-server/camel/camel-vee-folder.c	(working copy)
@@ -1539,7 +1539,27 @@
 
 	camel_vee_folder_hash_folder(sub, hash);
 
+	if (strstr(vf->expression, "match-threads")) {
+		/* The incremental-updating code below doesn't handle cases
+		 * where a newly matching message pulls in the rest of its
+		 * thread.  Thus, delete the source folder's contribution
+		 * from the DB so the next vee_rebuild_folder will be forced
+		 * to re-execute the search. */
+		int ret = camel_vee_summary_delete_ids(folder->summary, hash);
 
+		/* Also need to add the source folder to folders_changed so
+		 * that the next vee_refresh_info will call vee_rebuild_folder. */
+		CAMEL_VEE_FOLDER_LOCK(vf, changed_lock);
+		/* Weird: Original code at end of folder_changed_change had
+		 * "!= NULL", which seems to be the opposite of what we want!!! */
+		if (g_list_find(vf->priv->folders_changed, sub) == NULL)
+			vf->priv->folders_changed = g_list_prepend(vf->priv->folders_changed, sub);
+		CAMEL_VEE_FOLDER_UNLOCK(vf, changed_lock);
+
+		CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+		return;
+	}
+
 	/* Lookup anything before we lock anything, to avoid deadlock with build_folder */
 
 	/* Find newly added that match */
Index: evolution-data-server/camel/camel-db.c
===================================================================
--- evolution-data-server/camel/camel-db.c	(revision 9778)
+++ evolution-data-server/camel/camel-db.c	(working copy)
@@ -682,7 +682,24 @@
 	 return array;
 }
 
+/* MATT - Based on camel_db_delete_uid_from_vfolder, camel_db_get_vuids_from_vfolder */
 int
+camel_db_delete_vuids_from_vfolder (CamelDB *db, char *folder_name, char *filter, CamelException *ex)
+{
+	 char *del_query;
+	 char *tmp = g_strdup_printf("%s%%", filter ? filter:"");
+	 int ret;
+	 del_query = sqlite3_mprintf ("DELETE FROM %Q WHERE vuid LIKE %Q", folder_name, tmp);
+	 g_free(tmp);
+
+	 ret = camel_db_command (db, del_query, ex);
+	 
+	 sqlite3_free (del_query);
+	 CAMEL_DB_RELEASE_SQLITE_MEMORY;
+	 return ret;
+}
+
+int
 camel_db_add_to_vfolder (CamelDB *db, char *folder_name, char *vuid, CamelException *ex)
 {
 	 char *ins_query;
Index: evolution-data-server/camel/camel-db.h
===================================================================
--- evolution-data-server/camel/camel-db.h	(revision 9778)
+++ evolution-data-server/camel/camel-db.h	(working copy)
@@ -152,6 +152,7 @@
 int camel_db_delete_uid_from_vfolder (CamelDB *db, char *folder_name, char *vuid, CamelException *ex);
 int camel_db_delete_uid_from_vfolder_transaction (CamelDB *db, char *folder_name, char *vuid, CamelException *ex);
 GPtrArray * camel_db_get_vuids_from_vfolder (CamelDB *db, char *folder_name, char *filter, CamelException *ex);
+int camel_db_delete_vuids_from_vfolder (CamelDB *db, char *folder_name, char *filter, CamelException *ex);
 int camel_db_add_to_vfolder (CamelDB *db, char *folder_name, char *vuid, CamelException *ex);
 int camel_db_add_to_vfolder_transaction (CamelDB *db, char *folder_name, char *vuid, CamelException *ex);
 
Index: evolution-data-server/camel/camel-vee-summary.c
===================================================================
--- evolution-data-server/camel/camel-vee-summary.c	(revision 9778)
+++ evolution-data-server/camel/camel-vee-summary.c	(working copy)
@@ -413,6 +413,21 @@
 	return array;
 }
 
+/* MATT - Based on camel_vee_summary_get_ids */
+int
+camel_vee_summary_delete_ids (CamelVeeSummary *summary, char hash[8])
+{
+	char *shash = g_strdup_printf("%c%c%c%c%c%c%c%c", hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7]);
+	CamelFolderSummary *cfs = (CamelFolderSummary *)summary;
+	int ret;
+
+	/* FIXME[disk-summary] fix exception passing */
+	ret = camel_db_delete_vuids_from_vfolder(cfs->folder->parent_store->cdb_w, cfs->folder->full_name, shash, NULL);
+	g_free(shash);
+
+	return ret;
+}
+
 CamelVeeMessageInfo *
 camel_vee_summary_add(CamelVeeSummary *s, CamelFolderSummary *summary, const char *uid, const char hash[8])
 {
Index: evolution-data-server/camel/camel-vee-summary.h
===================================================================
--- evolution-data-server/camel/camel-vee-summary.h	(revision 9778)
+++ evolution-data-server/camel/camel-vee-summary.h	(working copy)
@@ -62,6 +62,7 @@
 
 CamelVeeMessageInfo * camel_vee_summary_add(CamelVeeSummary *s, CamelFolderSummary *summary, const char *uid, const char hash[8]);
 GPtrArray * camel_vee_summary_get_ids (CamelVeeSummary *summary, char hash[8]);
+int camel_vee_summary_delete_ids (CamelVeeSummary *summary, char hash[8]);
 
 G_END_DECLS
 
