Python: Fix python detection for non project files

Do not return an empty file path if we cannot find a python venv for a
file path, but also consider the configured interpreters.

Change-Id: I5a7f06e394fb925f9a00143fc5f0797e8754534b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-06-09 15:17:21 +02:00
parent 4c20a880e6
commit 99acc9a153

View File

@@ -67,8 +67,8 @@ FilePath detectPython(const FilePath &documentPath)
// check whether this file is inside a python virtual environment
QList<Interpreter> venvInterpreters = PythonSettings::detectPythonVenvs(documentPath);
if (!python.exists())
python = venvInterpreters.value(0).command;
if (!python.exists() && !venvInterpreters.isEmpty())
python = venvInterpreters.first().command;
if (!python.exists())
python = PythonSettings::defaultInterpreter().command;