Commit a8726def authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Kurt Hindenburg
Browse files

Avoid using wrong coordinates on extendSelection

It seems MR 659 exposed an old bug (sorry!).  When extending the selection
(shift + left mouse button) and there was no previous point of reference
(either a selection, or a previous mouse press, with no intervening
normal/alternate screen switches), extendSelection() was using the position
measured in _pixels_ instead of char cells to initialize the point of reference
for further selection extend operations.

Before MR 659, this tended to result in the selection extending from the mouse
position to the lower right corner on a subsequent selection extend operation.

Now, if there is no previous point of reference, use the cursor position.
Whether to also use the cursor position as point of reference if there is no
existing selection merits further consideration.

To reproduce the bug, open a new Konsole, and shift+LMB twice (once to set the
out of bounds point of reference, and another one to actually create a
selection) before doing any other mouse button presses.

BUG: 458822
BUG: 398320
parent 99c3bafb
Pipeline #250468 failed with stage
in 6 minutes and 7 seconds
......@@ -1298,8 +1298,9 @@ void TerminalDisplay::extendSelection(const QPoint &position)
if (_iPntSel.x() < 0 || _iPntSel.y() < 0 || _pntSel.x() < 0 || _pntSel.y() < 0) {
_iPntSel = _pntSel = position;
_iPntSel = _pntSel = _screenWindow->cursorPosition();
_iPntSel.ry() += _scrollBar->value();
_pntSel.ry() += _scrollBar->value();
// if ( !contentsRect().contains(ev->pos()) ) return;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment