forked from qt-creator/qt-creator
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user