[python] lsp: fix windows executable

GitOrigin-RevId: 3c328701a698a8486f3d6d191eb68def7e4e5891
This commit is contained in:
Morgan Bartholomew
2025-11-06 19:58:44 +10:00
committed by intellij-monorepo-bot
parent c3650beaf7
commit 4a15c51165

View File

@@ -20,12 +20,11 @@ val Editor.pythonSdk: Sdk?
fun Sdk.getExecutablePath(name: String): Path? = homePath?.let {
val base = Path(it)
if (OS.CURRENT == OS.Windows) {
val candidates = listOf("exe", "bat", "cmd", "com").map { ext -> Path(it + "." + ext) }
val found = candidates.firstNotNullOfOrNull { candidate -> PythonSdkUtil.getExecutablePath(candidate, name) }
found ?: PythonSdkUtil.getExecutablePath(base, name)
val candidates = if (OS.CURRENT == OS.Windows) {
listOf("exe", "bat", "cmd", "com").map { ext -> "$name.$ext" }.plusElement(name)
}
else {
PythonSdkUtil.getExecutablePath(base, name)
listOf(name)
}
candidates.firstNotNullOfOrNull { candidate -> PythonSdkUtil.getExecutablePath(base, candidate) }
}