make enter key behave better in chat input

This commit is contained in:
ouwou
2021-04-15 02:45:22 -04:00
parent cd8cd97c9b
commit 5d95daaeca

View File

@@ -42,13 +42,12 @@ bool ChatInput::ProcessKeyPress(GdkEventKey *event) {
auto buf = GetBuffer(); auto buf = GetBuffer();
auto text = buf->get_text(); auto text = buf->get_text();
// sometimes a message thats just newlines can sneak in if you hold down enter
if (text.size() > 0 && !std::all_of(text.begin(), text.end(), [](gunichar c) -> bool { return c == gunichar('\n'); })) { const bool accepted = m_signal_submit.emit(text);
const bool accepted = m_signal_submit.emit(text); if (accepted)
if (accepted) buf->set_text("");
buf->set_text("");
return true; return true;
}
} }
return false; return false;