From b071094f3f66bfc394748c2f2e161b37956291e1 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 18 Jun 2026 23:38:46 +0200 Subject: [PATCH 1/2] fix: Fix repeated message corrections in MUCs Avoid overwriting the stored last message ID in MUCs when an outgoing message is a correction. In 1:1 chats, we prevent overwriting the stored last_msg_id when sending a correction. In MUCs, last_msg_id was unconditionally overwritten with the ID of the correction message itself. XEP-0308: "If a message is corrected multiple times, every subsequent correction must reference the ID of the original message, not the ID of the previous correction." Signed-off-by: Michael Vetter --- src/ui/mucwin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 60259f842..811cbc2c8 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -493,8 +493,8 @@ mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* c win_print_outgoing_muc_msg(window, ch, mynick, id, replace_id, message); - // save last id and message for LMC - if (id) { + // save last id and message for LMC in case if it's not LMC message + if (id && !replace_id) { _mucwin_set_last_message(mucwin, id, message); } From fbebed391e1657a30a95b85084570e1f15633cdf Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 19 Jun 2026 09:11:52 +0200 Subject: [PATCH 2/2] refactor: Permit editing of latest correction in LMC Change behavior to update the stored "last message" buffer with the corrected text. Previously, the buffer purposely preserved the original message text, causing subsequent corrections to autocomplete back to the original message. With this change, subsequent corrections will autocomplete to and edit the most recently corrected text instead. This was requested by users in the MUC. And seems to be what other clients do as well. Signed-off-by: Michael Vetter --- src/ui/chatwin.c | 19 ++++++++++++------- src/ui/mucwin.c | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index cf50ae571..52c2915fc 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -402,9 +402,10 @@ chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, const char plugins_post_chat_message_display(myjid->barejid, myjid->resourcepart, display_message); - // save last id and message for LMC in case if it's not LMC message - if (id && !replace_id) { - _chatwin_set_last_message(chatwin, id, display_message); + // save last id and message for LMC + if (id) { + const char* const save_id = replace_id ? replace_id : id; + _chatwin_set_last_message(chatwin, save_id, display_message); } } @@ -609,9 +610,13 @@ chatwin_db_history(ProfChatWin* chatwin, const char* start_time, const char* end static void _chatwin_set_last_message(ProfChatWin* chatwin, const char* const id, const char* const message) { - free(chatwin->last_message); - chatwin->last_message = strdup(message); + if (chatwin->last_message != message) { + free(chatwin->last_message); + chatwin->last_message = strdup(message); + } - free(chatwin->last_msg_id); - chatwin->last_msg_id = strdup(id); + if (chatwin->last_msg_id != id) { + free(chatwin->last_msg_id); + chatwin->last_msg_id = strdup(id); + } } diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 811cbc2c8..6e308a769 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -493,9 +493,10 @@ mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* c win_print_outgoing_muc_msg(window, ch, mynick, id, replace_id, message); - // save last id and message for LMC in case if it's not LMC message - if (id && !replace_id) { - _mucwin_set_last_message(mucwin, id, message); + // save last id and message for LMC + if (id) { + const char* const save_id = replace_id ? replace_id : id; + _mucwin_set_last_message(mucwin, save_id, message); } wins_add_quotes_ac(window, message, FALSE); @@ -932,11 +933,15 @@ mucwin_unset_message_char(ProfMucWin* mucwin) static void _mucwin_set_last_message(ProfMucWin* mucwin, const char* const id, const char* const message) { - free(mucwin->last_message); - mucwin->last_message = strdup(message); + if (mucwin->last_message != message) { + free(mucwin->last_message); + mucwin->last_message = strdup(message); + } - free(mucwin->last_msg_id); - mucwin->last_msg_id = strdup(id); + if (mucwin->last_msg_id != id) { + free(mucwin->last_msg_id); + mucwin->last_msg_id = strdup(id); + } } gchar*