ClangFormat: Fix the filepath to actually pick the selected config

We've searched for the config we want to use but did not change
the path for the source file which is used internally by libformat
to find the configuration.

Fixes: QTCREATORBUG-22048
Change-Id: Ibdcc33ac338f06e966dfc5c06cdb38db3bb768b6
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2019-03-11 14:43:14 +01:00
parent cb3a553583
commit 3017ee23e5

View File

@@ -237,6 +237,12 @@ QString configForFile(Utils::FileName fileName)
return configForFile(fileName, true);
}
Utils::FileName assumedPathForConfig(const QString &configFile)
{
Utils::FileName fileName = Utils::FileName::fromString(configFile);
return fileName.parentDir().appendPath("test.cpp");
}
static clang::format::FormatStyle constructStyle(const QByteArray &baseStyle = QByteArray())
{
if (!baseStyle.isEmpty()) {
@@ -311,6 +317,7 @@ static clang::format::FormatStyle styleForFile(Utils::FileName fileName, bool ch
if (configFile.isEmpty())
return constructStyle();
fileName = assumedPathForConfig(configFile);
Expected<FormatStyle> style = format::getStyle("file",
fileName.toString().toStdString(),
"none");