--- imap.patch1.c	2018-05-08 14:22:58.970371174 +0800
+++ imap.patch2.c	2018-05-08 14:30:06.463398934 +0800
@@ -627,7 +627,13 @@
     free(mailbox);
   }
 
-  if(!result)
+  const char *p = imap->custom_params;
+  while(p && *p == ' ')
+    p++;
+  if(!result && imap->custom && (strcasecompare(imap->custom, "FETCH") ||
+    (strcasecompare(imap->custom, "UID") && p && strstr(p, "FETCH") == p)))
+    state(conn, IMAP_FETCH);
+  else if(!result)
     state(conn, IMAP_LIST);
 
   return result;
