From 3416ccd7ec9c441ddcd3aaafd9ad0cb603f05c6e Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Mon, 15 May 2023 15:55:50 +0200 Subject: 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: Reviewed-by: Cristian Adam --- src/plugins/terminal/terminalwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/terminal/terminalwidget.cpp b/src/plugins/terminal/terminalwidget.cpp index b3c7421a6a..b63e66b78d 100644 --- a/src/plugins/terminal/terminalwidget.cpp +++ b/src/plugins/terminal/terminalwidget.cpp @@ -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); -- cgit v1.2.1