forked from qt-creator/qt-creator
qmljs: improve suggestion ordering
change matchStrength sp that a contigous prefix is always preferred
Task-number: QTCREATORBUG-10638
Change-Id: I532d93eddae1ad39157ff65e96fc6651200264ab
Change-Id: I1001f5f4b78bac84b8df8ddc4c394c68359f7821
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -654,7 +654,7 @@ int matchStrength(const QString &searchStr, const QString &str)
|
||||
{
|
||||
QString::const_iterator i = searchStr.constBegin(), iEnd = searchStr.constEnd(),
|
||||
j = str.constBegin(), jEnd = str.constEnd();
|
||||
bool lastWasNotUpper=true, lastWasSpacer=true, lastWasMatch = false;
|
||||
bool lastWasNotUpper=true, lastWasSpacer=true, lastWasMatch = false, didJump = false;
|
||||
int res = 0;
|
||||
while (i != iEnd && j != jEnd) {
|
||||
bool thisIsUpper = (*j).isUpper();
|
||||
@@ -667,6 +667,7 @@ int matchStrength(const QString &searchStr, const QString &str)
|
||||
lastWasMatch = true;
|
||||
++i;
|
||||
} else {
|
||||
didJump = true;
|
||||
lastWasMatch = false;
|
||||
}
|
||||
++j;
|
||||
@@ -674,9 +675,11 @@ int matchStrength(const QString &searchStr, const QString &str)
|
||||
lastWasSpacer = !thisIsLetterOrNumber;
|
||||
}
|
||||
if (i != iEnd)
|
||||
return iEnd - i;
|
||||
return i - iEnd;
|
||||
if (j == jEnd)
|
||||
++res;
|
||||
if (!didJump)
|
||||
res+=2;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user