From 708e0fc06f45c4ad568a00fe665f3b94d4304ecb Mon Sep 17 00:00:00 2001 From: Maximilian Goldstein Date: Fri, 3 Dec 2021 14:39:52 +0100 Subject: [PATCH] qmljsinterpreter: Fix directory imports not being found in selector paths Previously qml files in selector paths would not properly locate directory imports, now when an import in a selector path fails we try to go up to the next non-selector directory and look for the imported directory there. Fixes: QTCREATORBUG-25127 Change-Id: Ib9b364981b49068637aa97d6f75abf7f1f5878cc Reviewed-by: Ulf Hermann --- src/libs/qmljs/qmljsinterpreter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 47951eeb28d..666d176e1d8 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -2258,6 +2258,14 @@ ImportInfo ImportInfo::pathImport(const QString &docPath, const QString &path, ? ImportType::QrcDirectory : ImportType::QrcFile; } else { + QDir dir(docPath); + while (dir.dirName().startsWith("+")) + dir.cdUp(); + + const QString docPathStripped = dir.absolutePath(); + if (docPathStripped != docPath) + return pathImport(docPathStripped, path, version, as, ast); + info.m_type = ImportType::UnknownFile; } info.m_version = version;