Commit 1b374905 authored by Leandro Melo's avatar Leandro Melo Committed by Leandro T. C. Melo

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/47Reviewed-by: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent 1c60ae10
......@@ -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;
}
......
Markdown is supported
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