C++: fix invalid common prefix calculation.

This was the indirect cause for "random" freezes when using
code-completion. The direct cause was a while loop counting down to 0,
but starting with a negative value. Both are fixed now.

Task-number: QTCREATORBUG-8472
Task-number: QTCREATORBUG-8532
Change-Id: I782a46be3ac8282d7484d0bf0c6fd30be6b171c8
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Erik Verbruggen
2013-01-10 16:41:14 +01:00
committed by Kai Koehne
parent 1675beebf3
commit 6ce9a80afa
2 changed files with 16 additions and 11 deletions

View File

@@ -344,7 +344,7 @@ void CppAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor *e
if (!inEditor.isEmpty()) {
preserveLength = toInsert.length() - (editor->position() - basePosition);
const int inEditorLength = inEditor.length();
while (preserveLength) {
while (preserveLength > 0) {
if (inEditor.startsWith(toInsert.right(preserveLength))
&& (inEditorLength == preserveLength
|| (!inEditor.at(preserveLength).isLetterOrNumber()