From 68ddabea5cb805af7e0e9817e4a6a43b290c31fe Mon Sep 17 00:00:00 2001 From: Viktor Oreshkin Date: Tue, 20 Jun 2017 23:01:10 +0300 Subject: [PATCH] Don't clear undo history when applying draft Signed-off-by: Viktor Oreshkin --- Telegram/SourceFiles/historywidget.cpp | 8 ++++---- Telegram/SourceFiles/historywidget.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index b1d0e6566f..ec547dc793 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -1715,10 +1715,10 @@ void HistoryWidget::fastShowAtEnd(History *h) { } } -void HistoryWidget::applyDraft(bool parseLinks) { +void HistoryWidget::applyDraft(bool parseLinks, Ui::FlatTextarea::UndoHistoryAction undoHistoryAction) { auto draft = _history ? _history->draft() : nullptr; if (!draft || !canWriteMessage()) { - clearFieldText(); + clearFieldText(0, undoHistoryAction); _field->setFocus(); _replyEditMsg = nullptr; _editMsgId = _replyToId = 0; @@ -1726,7 +1726,7 @@ void HistoryWidget::applyDraft(bool parseLinks) { } _textUpdateEvents = 0; - setFieldText(draft->textWithTags); + setFieldText(draft->textWithTags, 0, undoHistoryAction); _field->setFocus(); draft->cursor.applyTo(_field); _textUpdateEvents = TextUpdateEvent::SaveDraft | TextUpdateEvent::SendTyping; @@ -1753,7 +1753,7 @@ void HistoryWidget::applyDraft(bool parseLinks) { void HistoryWidget::applyCloudDraft(History *history) { if (_history == history && !_editMsgId) { - applyDraft(); + applyDraft(true, Ui::FlatTextarea::AddToUndoHistory); updateControlsVisibility(); updateControlsGeometry(); diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 575b5db305..606e515165 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -301,7 +301,7 @@ public: DragState getDragState(const QMimeData *d); void fastShowAtEnd(History *h); - void applyDraft(bool parseLinks = true); + void applyDraft(bool parseLinks = true, Ui::FlatTextarea::UndoHistoryAction undoHistoryAction = Ui::FlatTextarea::ClearUndoHistory); void showHistory(const PeerId &peer, MsgId showAtMsgId, bool reload = false); void clearDelayedShowAt(); void clearAllLoadRequests();