From 8b7cc1a0ed95e8a3ff413fa77eb12a3dca7fccb4 Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Fri, 7 Feb 2020 23:44:03 -0500 Subject: Clear completion for ID on self-part --- chat.h | 1 + complete.c | 12 ++++++++++++ handle.c | 3 +++ 3 files changed, 16 insertions(+) diff --git a/chat.h b/chat.h index aec5a68..6eeed60 100644 --- a/chat.h +++ b/chat.h @@ -154,6 +154,7 @@ void completeReject(void); void completeAdd(size_t id, const char *str, enum Color color); void completeTouch(size_t id, const char *str, enum Color color); void completeRemove(size_t id, const char *str); +void completeClear(size_t id); FILE *configOpen(const char *path, const char *mode); int getopt_config( diff --git a/complete.c b/complete.c index 5067512..437bb7d 100644 --- a/complete.c +++ b/complete.c @@ -122,3 +122,15 @@ void completeRemove(size_t id, const char *str) { free(node); } } + +void completeClear(size_t id) { + struct Node *next = NULL; + for (struct Node *node = head; node; node = next) { + next = node->next; + if (node->id != id) continue; + if (match == node) match = NULL; + detach(node); + free(node->str); + free(node); + } +} diff --git a/handle.c b/handle.c index 4faabba..b73d200 100644 --- a/handle.c +++ b/handle.c @@ -212,6 +212,9 @@ static void handleJoin(struct Message *msg) { static void handlePart(struct Message *msg) { require(msg, true, 1); size_t id = idFor(msg->params[0]); + if (self.nick && !strcmp(msg->nick, self.nick)) { + completeClear(id); + } completeRemove(id, msg->nick); uiFormat( id, Cold, tagTime(msg), -- cgit 1.4.1-2-gfad0