Clear completion for ID on self-part

master
C. McEnroe 2020-02-07 23:44:03 -05:00
parent d314523b90
commit 8b7cc1a0ed
3 changed files with 16 additions and 0 deletions

1
chat.h
View File

@ -154,6 +154,7 @@ void completeReject(void);
void completeAdd(size_t id, const char *str, enum Color color); void completeAdd(size_t id, const char *str, enum Color color);
void completeTouch(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 completeRemove(size_t id, const char *str);
void completeClear(size_t id);
FILE *configOpen(const char *path, const char *mode); FILE *configOpen(const char *path, const char *mode);
int getopt_config( int getopt_config(

View File

@ -122,3 +122,15 @@ void completeRemove(size_t id, const char *str) {
free(node); 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);
}
}

View File

@ -212,6 +212,9 @@ static void handleJoin(struct Message *msg) {
static void handlePart(struct Message *msg) { static void handlePart(struct Message *msg) {
require(msg, true, 1); require(msg, true, 1);
size_t id = idFor(msg->params[0]); size_t id = idFor(msg->params[0]);
if (self.nick && !strcmp(msg->nick, self.nick)) {
completeClear(id);
}
completeRemove(id, msg->nick); completeRemove(id, msg->nick);
uiFormat( uiFormat(
id, Cold, tagTime(msg), id, Cold, tagTime(msg),