Skip to content

Commit

Permalink
WSearchLineEdit: don't trigger search when pressing cursor keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Feb 20, 2023
1 parent cb02680 commit ed10381
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/widget/wsearchlineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ QString WSearchLineEdit::getSearchText() const {
if (pCompleter && pEdit && pEdit->hasSelectedText()) {
if (text.startsWith(pCompleter->completionPrefix()) &&
pCompleter->completionPrefix().size() == pEdit->cursorPosition()) {
// Search for the entered text until the user has confirmed the
// completion by -> or enter
// Search for the entered text until the user has accepted the
// completion by pressing Enter or changed/deselected the selected
// completion text with Right or Left key
return pCompleter->completionPrefix();
}
}
Expand Down Expand Up @@ -387,10 +388,16 @@ void WSearchLineEdit::keyPressEvent(QKeyEvent* keyEvent) {
}
break;
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Right: {
// Both keys change or clear the selection (suggested completion).
// Don't search immediately but let slotTextChanged() engage the debounce timer.
QLineEdit* pEdit = lineEdit();
DEBUG_ASSERT(pEdit);
QString text = pEdit->text();
QComboBox::keyPressEvent(keyEvent);
slotTriggerSearch();
slotTextChanged(text);
return;
}
case Qt::Key_Enter:
case Qt::Key_Return: {
if (slotClearSearchIfClearButtonHasFocus()) {
Expand Down

0 comments on commit ed10381

Please sign in to comment.