Terminal: Fix selection warning

When quickly selection text via double-clicking and moving the mouse to the left
it is possible that a selection is created where the start == end.
This was incorrectly reported as a warning.

Task-number: QTCREATORBUG-30144
Change-Id: I37b22f4ee725e5085ce0090c123ccfd9980b8a59
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-01-09 08:14:19 +01:00
parent 7942c36ace
commit 99078778cc

View File

@@ -386,10 +386,13 @@ QString TerminalView::textFromSelection() const
if (!d->m_selection) if (!d->m_selection)
return {}; return {};
if (d->m_selection->start == d->m_selection->end)
return {};
CellIterator it = d->m_surface->iteratorAt(d->m_selection->start); CellIterator it = d->m_surface->iteratorAt(d->m_selection->start);
CellIterator end = d->m_surface->iteratorAt(d->m_selection->end); CellIterator end = d->m_surface->iteratorAt(d->m_selection->end);
if (it.position() >= end.position()) { if (it.position() > end.position()) {
qCWarning(selectionLog) << "Invalid selection: start >= end"; qCWarning(selectionLog) << "Invalid selection: start >= end";
return {}; return {};
} }