From fda2f56fd80b29f9b5267127246272bf85a2b83a Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 27 Jun 2023 20:26:43 +0400 Subject: [PATCH] Don't copy empty selected text. --- Telegram/SourceFiles/history/history_inner_widget.cpp | 6 ++++-- .../SourceFiles/history/view/history_view_context_menu.cpp | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 857803c17..cd2fa4685 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2341,7 +2341,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { const auto item = _dragStateItem; const auto itemId = item ? item->fullId() : FullMsgId(); if (isUponSelected > 0) { - if (!hasCopyRestrictionForSelected()) { + if (!hasCopyRestrictionForSelected() + && !getSelectedText().empty()) { _menu->addAction( (isUponSelected > 1 ? tr::lng_context_copy_selected_items(tr::now) @@ -2442,7 +2443,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { : QString(); if (isUponSelected > 0) { - if (!hasCopyRestrictionForSelected()) { + if (!hasCopyRestrictionForSelected() + && !getSelectedText().empty()) { _menu->addAction( ((isUponSelected > 1) ? tr::lng_context_copy_selected_items(tr::now) diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 4992cca85..be51f4b50 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -995,7 +995,9 @@ base::unique_qptr FillContextMenu( list, st::popupMenuWithIcons); - if (request.overSelection && !list->hasCopyRestrictionForSelected()) { + if (request.overSelection + && !list->hasCopyRestrictionForSelected() + && !list->getSelectedText().empty()) { const auto text = request.selectedItems.empty() ? tr::lng_context_copy_selected(tr::now) : tr::lng_context_copy_selected_items(tr::now);