diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7ed1bb86e..51991fd4e 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1229,9 +1229,9 @@ boolean HU_Responder(event_t *ev) && !G_ControlBoundToKey(0, gc_talkkey, ev->data1, false)) return false; - M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete); - - if (c == KEY_ENTER) + if (M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete)) + ; // Do nothing + else if (c == KEY_ENTER) { if (!CHAT_MUTE) HU_sendChatMessage(); @@ -1776,7 +1776,7 @@ static void HU_DrawChat(void) } } - if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 0)) + if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 1)) { emote_t *suggest; int skip = 0; diff --git a/src/m_textinput.c b/src/m_textinput.c index 8813d45e1..0a6f31467 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -425,10 +425,10 @@ static int M_TextInputEmoteStart(textinput_t *input) return emotestart; } -static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *autocomplete) +static boolean M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *autocomplete) { if (input->cursor == 0) - return; + return false; // If we're in "autocomplete" state, delete ':' for latest autocompleted emote if (autocomplete->complete[0]) @@ -447,8 +447,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a int emotestart = autocomplete->emotestart; // No emote - no autocomplete - if (emotestart == -1 || (size_t)emotestart == input->cursor) - return; + if (emotestart == -1 || input->cursor - emotestart < 2) + return false; strlcpy(autocomplete->complete, &input->buffer[emotestart], input->cursor-emotestart+1); } @@ -466,7 +466,7 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a { // Clear autocompletion state autocomplete->complete[0] = 0; - return; + return false; } } @@ -478,6 +478,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a M_TextInputAddString(input, completed->name); M_TextInputAddChar(input, ':'); + + return true; } boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplete_t *autocomplete) @@ -493,7 +495,8 @@ boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplet if (key == '\t' || (autocomplete->complete[0] == 0 && key == KEY_ENTER)) { - M_TextInputCompleteEmote(input, autocomplete); + if (M_TextInputCompleteEmote(input, autocomplete) && key == KEY_ENTER) // Don't send message if we've autocompleted an emote + ret = true; } else {