forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.11'
Change-Id: Ie951c531a5b2efd8e6b972c4d04b7f1c681c8ef9
This commit is contained in:
@@ -530,7 +530,7 @@ QList<Interpreter> PythonSettings::detectPythonVenvs(const FilePath &path)
|
||||
void PythonSettings::saveSettings()
|
||||
{
|
||||
const QList<Interpreter> &interpreters = interpreterOptionsPage().interpreters();
|
||||
const QString &defaultId = interpreterOptionsPage().defaultInterpreter().id;
|
||||
const QString defaultId = interpreterOptionsPage().defaultInterpreter().id;
|
||||
toSettings(Core::ICore::settings(), {interpreters, defaultId});
|
||||
if (QTC_GUARD(settingsInstance))
|
||||
emit settingsInstance->interpretersChanged(interpreters, defaultId);
|
||||
|
||||
@@ -94,6 +94,11 @@ static QString pythonName(const FilePath &pythonPath)
|
||||
|
||||
FilePath getPylsModulePath(CommandLine pylsCommand)
|
||||
{
|
||||
static QMap<FilePath, FilePath> cache;
|
||||
const FilePath &modulePath = cache.value(pylsCommand.executable());
|
||||
if (!modulePath.isEmpty())
|
||||
return modulePath;
|
||||
|
||||
pylsCommand.addArg("-h");
|
||||
SynchronousProcess pythonProcess;
|
||||
pythonProcess.setEnvironment(pythonProcess.environment() + QStringList("PYTHONVERBOSE=x"));
|
||||
@@ -111,8 +116,11 @@ FilePath getPylsModulePath(CommandLine pylsCommand)
|
||||
const QString &output = response.allOutput();
|
||||
for (auto regex : {regexCached, regexNotCached}) {
|
||||
QRegularExpressionMatch result = regex.match(output);
|
||||
if (result.hasMatch())
|
||||
return FilePath::fromUserInput(result.captured(1));
|
||||
if (result.hasMatch()) {
|
||||
const FilePath &modulePath = FilePath::fromUserInput(result.captured(1));
|
||||
cache[pylsCommand.executable()] = modulePath;
|
||||
return modulePath;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -146,7 +154,7 @@ static PythonLanguageServerState checkPythonLanguageServer(const FilePath &pytho
|
||||
}
|
||||
}
|
||||
|
||||
return {PythonLanguageServerState::AlreadyInstalled, getPylsModulePath(pythonLShelpCommand)};
|
||||
return {PythonLanguageServerState::AlreadyInstalled, modulePath};
|
||||
}
|
||||
|
||||
const CommandLine pythonPipVersionCommand(python, {"-m", "pip", "-V"});
|
||||
|
||||
Reference in New Issue
Block a user