Incorrect Autocompletion in /correct Command #24

Closed
opened 2025-09-01 22:16:14 +00:00 by jabber.developer · 0 comments

Description

The /correct command's autocompletion feature incorrectly suggests the original message content (e.g., Hello) instead of the corrected message content (e.g., Hi) when using Last Message Correction (LMC). This occurs because chatwin_outgoing_msg only calls _chatwin_set_last_message for original messages (when replace_id is NULL), preventing the message content from being updated for autocompletion.

Steps to Reproduce

  1. Send a message Hello.
  2. Use /correct Hi to replace it with a new message.
  3. Type /correct and press <tab> for autocompletion.
  4. Observe that autocompletion suggests /correct Hello (original message) instead of /correct Hi (corrected message).

Expected Behavior

Autocompletion for /correct should suggest the corrected message content (e.g., /correct Hi).

Root Cause

In chatwin_outgoing_msg, _chatwin_set_last_message is only called when replace_id is NULL (original messages). This prevents the corrected message content from being stored for autocompletion, causing /correct to suggest the original message content.

Proposed Fix

Modify chatwin_outgoing_msg to call _chatwin_set_last_message for both original and corrected messages, using replace_id (if present) or id to preserve the original message ID (as per XEP-0308), while updating the message content for autocompletion.

Add unit tests to verify:

  • Autocompletion suggests the corrected message content.
  • The original message ID is preserved for LMC corrections.

https://github.com/profanity-im/profanity/issues/1899#issuecomment-1769942338

## Description The `/correct` command's autocompletion feature incorrectly suggests the original message content (e.g., `Hello`) instead of the corrected message content (e.g., `Hi`) when using Last Message Correction (LMC). This occurs because `chatwin_outgoing_msg` only calls `_chatwin_set_last_message` for original messages (when `replace_id` is `NULL`), preventing the message content from being updated for autocompletion. ## Steps to Reproduce 1. Send a message `Hello`. 2. Use `/correct Hi` to replace it with a new message. 3. Type `/correct` and press `<tab>` for autocompletion. 4. Observe that autocompletion suggests `/correct Hello` (original message) instead of `/correct Hi` (corrected message). ## Expected Behavior Autocompletion for `/correct` should suggest the corrected message content (e.g., `/correct Hi`). ## Root Cause In `chatwin_outgoing_msg`, `_chatwin_set_last_message` is only called when `replace_id` is `NULL` (original messages). This prevents the corrected message content from being stored for autocompletion, causing `/correct` to suggest the original message content. ## Proposed Fix Modify `chatwin_outgoing_msg` to call `_chatwin_set_last_message` for both original and corrected messages, using `replace_id` (if present) or `id` to preserve the original message ID (as per [XEP-0308](https://xmpp.org/extensions/xep-0308.html)), while updating the message content for autocompletion. Add unit tests to verify: - Autocompletion suggests the corrected message content. - The original message ID is preserved for LMC corrections. ## Related Issues https://github.com/profanity-im/profanity/issues/1899#issuecomment-1769942338
jabber.developer self-assigned this 2025-09-01 22:23:16 +00:00
jabber.developer removed their assignment 2025-09-01 22:23:46 +00:00
jabber.developer added the
Kind/Bug
label 2025-09-01 22:24:42 +00:00
admin closed this issue 2025-09-02 12:20:54 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: devs/cproof#24
No description provided.