From 03e617a146666ad95f8cf9ff144f1cec4ae4c6cd Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sat, 15 Jul 2023 16:03:33 -0400 Subject: [PATCH] only start editing if input is empty --- src/components/chatinput.cpp | 4 ++++ src/components/chatinput.hpp | 2 ++ src/components/chatwindow.cpp | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp index c88de49f..f53c6fe0 100644 --- a/src/components/chatinput.cpp +++ b/src/components/chatinput.cpp @@ -579,6 +579,10 @@ void ChatInput::StopEditing() { m_input.Get().get_style_context()->remove_class("editing"); } +bool ChatInput::IsEmpty() { + return GetBuffer()->get_char_count() == 0; +} + bool ChatInput::AddFileAsImageAttachment(const Glib::RefPtr &file) { try { const auto read_stream = file->read(); diff --git a/src/components/chatinput.hpp b/src/components/chatinput.hpp index c98d9359..393a9aaa 100644 --- a/src/components/chatinput.hpp +++ b/src/components/chatinput.hpp @@ -143,6 +143,8 @@ class ChatInput : public Gtk::Box { void StartEditing(const Message &message); void StopEditing(); + bool IsEmpty(); + private: bool AddFileAsImageAttachment(const Glib::RefPtr &file); bool CanAttachFiles(); diff --git a/src/components/chatwindow.cpp b/src/components/chatwindow.cpp index dcff656e..17f5601d 100644 --- a/src/components/chatwindow.cpp +++ b/src/components/chatwindow.cpp @@ -287,7 +287,7 @@ bool ChatWindow::OnInputSubmit(ChatSubmitParams data) { bool ChatWindow::ProcessKeyEvent(GdkEventKey *e) { if (e->type != GDK_KEY_PRESS) return false; - if (e->keyval == GDK_KEY_Up) { + if (e->keyval == GDK_KEY_Up && !(e->state & GDK_SHIFT_MASK) && m_input->IsEmpty()) { const auto edit_id = m_chat->GetLastSentMessage(); if (edit_id.has_value()) { StartEditing(*edit_id);