FileInProjectFinder: Fix path analysis

The previous code let to all possible paths to be accepted with maximum
confidence.

Fixes: QTCREATORBUG-29090
Change-Id: I3e0876d2fd1a5636dbe45cf152c8a251316185ff
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Ulf Hermann
2023-04-26 14:47:02 +02:00
committed by Tim Jenssen
parent 1fe7b77393
commit 8482e2405e

View File

@@ -248,7 +248,10 @@ bool FileInProjectFinder::findFileOrDirectory(const FilePath &originalPath, File
}
}
while (prefixToIgnore != -1) {
FilePath candidate = originalPath.resolvePath(m_projectDir);
QString candidateString = originalPath.toFSPathString();
candidateString.remove(0, prefixToIgnore);
candidateString.prepend(m_projectDir.toString());
const FilePath candidate = FilePath::fromString(candidateString);
const int matchLength = origLength - prefixToIgnore;
// FIXME: This might be a worse match than what we find later.
if (checkPath(candidate, matchLength, fileHandler, directoryHandler)) {