[python] cleanup: Introduce PathSortener.shorten and obey case sensitivity.

1. utility method added
2. paths checked with correct case sensitivity

GitOrigin-RevId: a2d0917df2a1e4f0a1d3d33fbb1f403d1342cf8c
This commit is contained in:
Ilya.Kazakevich
2025-11-14 05:37:37 +00:00
committed by intellij-monorepo-bot
parent 7d26f2e8a6
commit 3a3053b63b
2 changed files with 16 additions and 20 deletions
@@ -1,15 +1,13 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.python.community.services.internal.impl
import com.intellij.platform.eel.EelPlatform
import com.intellij.platform.eel.provider.asNioPath
import com.intellij.platform.eel.provider.getEelDescriptor
import com.intellij.python.community.execService.python.validatePythonAndGetInfo
import com.intellij.python.community.services.internal.impl.VanillaPythonWithPythonInfoImpl.Companion.concurrentLimit
import com.intellij.python.community.services.internal.impl.VanillaPythonWithPythonInfoImpl.Companion.createByPythonBinary
import com.intellij.python.community.services.shared.PythonInfoComparator
import com.intellij.python.community.services.shared.PythonWithPythonInfo
import com.intellij.python.community.services.shared.VanillaPythonWithPythonInfo
import com.jetbrains.python.PathShortener
import com.jetbrains.python.PythonBinary
import com.jetbrains.python.PythonInfo
import com.jetbrains.python.Result
@@ -21,8 +19,6 @@ import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit
import org.jetbrains.annotations.ApiStatus.Internal
import org.jetbrains.annotations.Nls
import kotlin.io.path.pathString
import kotlin.io.path.relativeTo
@Internal
class VanillaPythonWithPythonInfoImpl internal constructor(
@@ -73,14 +69,7 @@ class VanillaPythonWithPythonInfoImpl internal constructor(
}
override suspend fun getReadableName(): @Nls String {
val eelApi = pythonBinary.getEelDescriptor().toEelApi()
val home = eelApi.userInfo.home.asNioPath()
val separator = when (eelApi.platform) {
is EelPlatform.Windows -> "\\"
is EelPlatform.Posix -> "/"
}
val pythonString = (if (pythonBinary.startsWith(home)) "~$separator" + pythonBinary.relativeTo(home).pathString
else pythonBinary.pathString)
val pythonString = PathShortener.shorten(pythonBinary)
return "$pythonString ($pythonInfo)"
}