aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/clangformat
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2019-03-11 14:43:14 +0100
committerIvan Donchevskii <ivan.donchevskii@qt.io>2019-03-12 10:10:37 +0000
commit3017ee23e5502d6ba8dc6b64eb023caf6c278069 (patch)
tree48a98c531e1a0e5f733692c5bc107518a944ba5d /src/plugins/clangformat
parentcb3a553583c66730106f40c070b075ad3ac4d381 (diff)
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>
Diffstat (limited to 'src/plugins/clangformat')
-rw-r--r--src/plugins/clangformat/clangformatutils.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/plugins/clangformat/clangformatutils.cpp b/src/plugins/clangformat/clangformatutils.cpp
index 45ed4feacf1..74c4165a34b 100644
--- a/src/plugins/clangformat/clangformatutils.cpp
+++ b/src/plugins/clangformat/clangformatutils.cpp
@@ -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");