From 99078778cc0783f0d093e46ddb36549c3fc395c4 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 9 Jan 2024 08:14:19 +0100 Subject: [PATCH] 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: Reviewed-by: Christian Stenger --- src/libs/solutions/terminal/terminalview.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/solutions/terminal/terminalview.cpp b/src/libs/solutions/terminal/terminalview.cpp index 2244ea62d73..210ede1b794 100644 --- a/src/libs/solutions/terminal/terminalview.cpp +++ b/src/libs/solutions/terminal/terminalview.cpp @@ -386,10 +386,13 @@ QString TerminalView::textFromSelection() const if (!d->m_selection) return {}; + if (d->m_selection->start == d->m_selection->end) + return {}; + CellIterator it = d->m_surface->iteratorAt(d->m_selection->start); 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"; return {}; }