From 230b98ce76c79b659b1d9408cf11b5c7166efde4 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 26 Jul 2022 16:23:00 +0200 Subject: [PATCH] clangd: Add ability to change --limit-results A user can set a value to the QTC_CLANGD_COMPLETION_RESULTS environment variable which will be passed as argument to clangd's --limit-results. The clangd default value is 100. Task-number: QTCREATORBUG-27152 Change-Id: Ic3e512a735fda1540b4f0ab56e39f9c5f0213e79 Reviewed-by: Eike Ziller Reviewed-by: Christian Kandeler Reviewed-by: --- src/plugins/clangcodemodel/clangdclient.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index 6699242283e..4c72aba34c7 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -273,8 +273,13 @@ static BaseClientInterface *clientInterface(Project *project, const Utils::FileP indexingOption += "=0"; const QString headerInsertionOption = QString("--header-insertion=") + (settings.autoIncludeHeaders() ? "iwyu" : "never"); + + bool ok = false; + const int userValue = qEnvironmentVariableIntValue("QTC_CLANGD_COMPLETION_RESULTS", &ok); + const QString limitResults = QString("--limit-results=%1").arg(ok ? userValue : 0); + Utils::CommandLine cmd{settings.clangdFilePath(), {indexingOption, headerInsertionOption, - "--limit-results=0", "--limit-references=0", "--clang-tidy=0"}}; + limitResults, "--limit-references=0", "--clang-tidy=0"}}; if (settings.workerThreadLimit() != 0) cmd.addArg("-j=" + QString::number(settings.workerThreadLimit())); if (!jsonDbDir.isEmpty())