From dc8abc74ed4d72a73315550b91283ff1f2e44199 Mon Sep 17 00:00:00 2001
From: 23rd <23rd@vivaldi.net>
Date: Sun, 11 Nov 2018 02:35:18 +0300
Subject: [PATCH] Fixed editing of the last message on KeyUp. Skip stickers,
 video-messages, call-messages and edit following message.

---
 Telegram/SourceFiles/history/history.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp
index 55b53c433d..5a5af1990a 100644
--- a/Telegram/SourceFiles/history/history.cpp
+++ b/Telegram/SourceFiles/history/history.cpp
@@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 #include "styles/style_dialogs.h"
 #include "data/data_drafts.h"
 #include "data/data_session.h"
+#include "data/data_media_types.h"
 #include "lang/lang_keys.h"
 #include "apiwrap.h"
 #include "mainwidget.h"
@@ -2405,6 +2406,10 @@ HistoryItem *History::lastSentMessage() const {
 	for (const auto &block : base::reversed(blocks)) {
 		for (const auto &message : base::reversed(block->messages)) {
 			const auto item = message->data();
+			// Skip if message is video message or sticker.
+			if (const auto media = item->media()) {
+				if (!media->allowsEditCaption()) continue;
+			}
 			if (IsServerMsgId(item->id)
 				&& !item->serviceMsg()
 				&& (item->out() || peer->isSelf())) {