forked from qt-creator/qt-creator
Completion: Make sure activation sequence has correct length
This is necessary for the very first characters typed on the editor in the case the activation sequence length is greater than one. Change-Id: I9ec611f816278795b7ac3f75913fccf5a52165bf Reviewed-on: http://codereview.qt.nokia.com/47 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
committed by
Leandro T. C. Melo
parent
1c60ae1039
commit
1b374905f9
@@ -126,6 +126,7 @@ private:
|
||||
bool m_receivedContentWhileWaiting;
|
||||
QTimer m_automaticProposalTimer;
|
||||
CompletionSettings m_settings;
|
||||
static const QChar m_null;
|
||||
};
|
||||
|
||||
} // TextEditor
|
||||
@@ -133,6 +134,8 @@ private:
|
||||
// --------------------
|
||||
// CodeAssistantPrivate
|
||||
// --------------------
|
||||
const QChar CodeAssistantPrivate::m_null;
|
||||
|
||||
CodeAssistantPrivate::CodeAssistantPrivate(CodeAssistant *assistant)
|
||||
: m_q(assistant)
|
||||
, m_textEditor(0)
|
||||
@@ -373,7 +376,10 @@ CompletionAssistProvider *CodeAssistantPrivate::identifyActivationSequence()
|
||||
const int length = provider->activationCharSequenceLength();
|
||||
if (length == 0)
|
||||
continue;
|
||||
const QString &sequence = m_textEditor->textAt(m_textEditor->position() - length, length);
|
||||
QString sequence = m_textEditor->textAt(m_textEditor->position() - length, length);
|
||||
const int lengthDiff = length - sequence.length();
|
||||
for (int j = 0; j < lengthDiff; ++j)
|
||||
sequence.prepend(m_null);
|
||||
if (provider->isActivationCharSequence(sequence))
|
||||
return provider;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user