Separate completeID state from complete state

I think this is what causes QUITs to sometimes not appear, because
wherever the complete match is skips over some IDs.
weechat-hashes
C. McEnroe 2020-04-23 20:22:15 -04:00
parent a632ee741b
commit 88263cc1d7
1 changed files with 6 additions and 2 deletions

View File

@ -117,9 +117,11 @@ void completeReject(void) {
match = NULL; match = NULL;
} }
static struct Node *iter;
uint completeID(const char *str) { uint completeID(const char *str) {
for (match = (match ? match->next : head); match; match = match->next) { for (iter = (iter ? iter->next : head); iter; iter = iter->next) {
if (match->id && !strcmp(match->str, str)) return match->id; if (iter->id && !strcmp(iter->str, str)) return iter->id;
} }
return None; return None;
} }
@ -144,6 +146,7 @@ void completeRemove(uint id, const char *str) {
if (id && node->id != id) continue; if (id && node->id != id) continue;
if (strcmp(node->str, str)) continue; if (strcmp(node->str, str)) continue;
if (match == node) match = NULL; if (match == node) match = NULL;
if (iter == node) iter = NULL;
detach(node); detach(node);
free(node->str); free(node->str);
free(node); free(node);
@ -156,6 +159,7 @@ void completeClear(uint id) {
next = node->next; next = node->next;
if (node->id != id) continue; if (node->id != id) continue;
if (match == node) match = NULL; if (match == node) match = NULL;
if (iter == node) iter = NULL;
detach(node); detach(node);
free(node->str); free(node->str);
free(node); free(node);