diff --git a/src/main/kotlin/com/github/pyvenvmanage/VenvProjectViewNodeDecorator.kt b/src/main/kotlin/com/github/pyvenvmanage/VenvProjectViewNodeDecorator.kt index 9d67d5e..2f928d4 100644 --- a/src/main/kotlin/com/github/pyvenvmanage/VenvProjectViewNodeDecorator.kt +++ b/src/main/kotlin/com/github/pyvenvmanage/VenvProjectViewNodeDecorator.kt @@ -15,10 +15,12 @@ class VenvProjectViewNodeDecorator : ProjectViewNodeDecorator { val pyVenvCfgPath = VenvUtils.getPyVenvCfg(node.getVirtualFile()) if (pyVenvCfgPath != null) { val pythonVersion = VenvUtils.getPythonVersionFromPyVenv(pyvenvCfgPath = pyVenvCfgPath) - val fileName: String? = data.getPresentableText() - data.clearText() - data.addText(fileName, SimpleTextAttributes.REGULAR_ATTRIBUTES) - data.addText(" [" + pythonVersion + "]", SimpleTextAttributes.GRAY_ATTRIBUTES) + if (pythonVersion != null) { + val fileName: String? = data.getPresentableText() + data.clearText() + data.addText(fileName, SimpleTextAttributes.REGULAR_ATTRIBUTES) + data.addText(" [$pythonVersion]", SimpleTextAttributes.GRAY_ATTRIBUTES) + } data.setIcon(Virtualenv) } } diff --git a/src/main/kotlin/com/github/pyvenvmanage/VenvUtils.kt b/src/main/kotlin/com/github/pyvenvmanage/VenvUtils.kt index f4be217..c539904 100644 --- a/src/main/kotlin/com/github/pyvenvmanage/VenvUtils.kt +++ b/src/main/kotlin/com/github/pyvenvmanage/VenvUtils.kt @@ -27,9 +27,7 @@ object VenvUtils { } @JvmStatic - fun getPythonVersionFromPyVenv(pyvenvCfgPath: Path): String { - val unknownVersion = "unknown" - + fun getPythonVersionFromPyVenv(pyvenvCfgPath: Path): String? { val props = Properties() try { @@ -37,14 +35,14 @@ object VenvUtils { props.load(reader) } } catch (e: IOException) { - return unknownVersion // file could not be read + return null // file could not be read } - val version = props.getProperty("version_info") + val version = props.getProperty("version") if (version != null) { return version.trim { it <= ' ' } } - return unknownVersion + return null } }