From 7e4cd9b3684b05b1a711e980bf43c0474267d21e Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Fri, 13 Dec 2019 22:22:00 +0100 Subject: [PATCH] FancyLineEdit: Fix camel case navigation with shift modifier Fixes: QTCREATORBUG-23370 Change-Id: Ie96f642f0b964499ded830ae6eabfc86ef31fabd Reviewed-by: David Schulz --- src/libs/utils/fancylineedit.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/libs/utils/fancylineedit.cpp b/src/libs/utils/fancylineedit.cpp index d67c3365440..928a612d438 100644 --- a/src/libs/utils/fancylineedit.cpp +++ b/src/libs/utils/fancylineedit.cpp @@ -370,15 +370,20 @@ void FancyLineEdit::onEditingFinished() void FancyLineEdit::keyPressEvent(QKeyEvent *event) { - const QTextCursor::MoveMode mode = (event->modifiers() & Qt::ShiftModifier) - ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor; - - if (camelCaseNavigation && event == QKeySequence::MoveToPreviousWord) - CamelCaseCursor::left(this, mode); - else if (camelCaseNavigation && event == QKeySequence::MoveToNextWord) - CamelCaseCursor::right(this, mode); - else + if (camelCaseNavigation) { + if (event == QKeySequence::MoveToPreviousWord) + CamelCaseCursor::left(this, QTextCursor::MoveAnchor); + else if (event == QKeySequence::SelectPreviousWord) + CamelCaseCursor::left(this, QTextCursor::KeepAnchor); + else if (event == QKeySequence::MoveToNextWord) + CamelCaseCursor::right(this, QTextCursor::MoveAnchor); + else if (event == QKeySequence::SelectNextWord) + CamelCaseCursor::right(this, QTextCursor::KeepAnchor); + else + QLineEdit::keyPressEvent(event); + } else { QLineEdit::keyPressEvent(event); + } } void FancyLineEdit::setCamelCaseNavigationEnabled(bool enabled)