Terminal: Fix selection

When moving the mouse left or right out of the viewport
the selection would grow into the previous/next line
without the bounding.

Change-Id: Ica38eac3b306338ef24aa4abace66f110edb2aef
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-05-15 15:55:50 +02:00
parent 22fa5f2d3a
commit 3416ccd7ec

View File

@@ -1313,8 +1313,11 @@ void TerminalWidget::mouseMoveEvent(QMouseEvent *event)
m_scrollTimer.setInterval(scrollInterval);
}
QPoint posBoundedToViewport = event->pos();
posBoundedToViewport.setX(qBound(0, posBoundedToViewport.x(), viewport()->width()));
int start = m_surface->gridToPos(globalToGrid(m_activeMouseSelect.start));
int newEnd = m_surface->gridToPos(globalToGrid(viewportToGlobal(event->pos())));
int newEnd = m_surface->gridToPos(globalToGrid(viewportToGlobal(posBoundedToViewport)));
if (start > newEnd) {
std::swap(start, newEnd);