From 77c212329aaac92b54c0d164555f7ab0069d9f5e Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Wed, 16 Oct 2013 12:22:31 +0200 Subject: [PATCH] CodeAssit: Fix completion if function hint is shown This reverts commit c5dfcce948dd40dac4f1a22d97a53afc5c6b7494, but the bug addressed by that commit remains fixed. FunctionHintProposals need to be fragile so they can be replaced by e.g. GenericProposals. Only one proposal can be "active". Change-Id: Ibca40063d46b8ef3bce4d72be7488f70885e75da Reviewed-by: David Schulz --- .../codeassist/functionhintproposal.cpp | 2 +- .../codeassist/functionhintproposalwidget.cpp | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/texteditor/codeassist/functionhintproposal.cpp b/src/plugins/texteditor/codeassist/functionhintproposal.cpp index 0a46436b91b..226d50308b7 100644 --- a/src/plugins/texteditor/codeassist/functionhintproposal.cpp +++ b/src/plugins/texteditor/codeassist/functionhintproposal.cpp @@ -43,7 +43,7 @@ FunctionHintProposal::~FunctionHintProposal() bool FunctionHintProposal::isFragile() const { - return false; + return true; } int FunctionHintProposal::basePosition() const diff --git a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp index e0023976c0e..d74878f2f21 100644 --- a/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp +++ b/src/plugins/texteditor/codeassist/functionhintproposalwidget.cpp @@ -212,13 +212,18 @@ bool FunctionHintProposalWidget::eventFilter(QObject *obj, QEvent *e) return false; } break; - case QEvent::KeyRelease: - if (static_cast(e)->key() == Qt::Key_Escape && d->m_escapePressed) { - abort(); - emit explicitlyAborted(); - return false; + case QEvent::KeyRelease: { + QKeyEvent *ke = static_cast(e); + if (ke->key() == Qt::Key_Escape && d->m_escapePressed) { + abort(); + emit explicitlyAborted(); + return false; + } else if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { + if (d->m_model->size() > 1) + return false; + } + d->m_assistant->notifyChange(); } - d->m_assistant->notifyChange(); break; case QEvent::WindowDeactivate: case QEvent::FocusOut: