Skip to content

Commit b67f5df

Browse files
committed
Fix available libraries listing version
This commit adds support for displaying plugin_host specific versions of available libraries.
1 parent 6aba0a9 commit b67f5df

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

package_control/commands/list_available_libraries_command.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ..console_write import console_write
1111
from ..package_manager import PackageManager
1212
from ..show_error import show_message
13+
from ..sys_path import python_versions
1314

1415
USE_QUICK_PANEL_ITEM = hasattr(sublime, "QuickPanelItem")
1516

@@ -48,9 +49,29 @@ def show_quick_panel():
4849

4950
threading.Thread(target=show_quick_panel).start()
5051

52+
@staticmethod
53+
def latest_releases(releases):
54+
versions = []
55+
for pyver in python_versions():
56+
for release in releases:
57+
if pyver in release["python_versions"]:
58+
versions.append([release["version"], pyver])
59+
break
60+
61+
if not versions:
62+
return ""
63+
64+
if len(versions) > 1 and versions[0][0] != versions[1][0]:
65+
return ",".join(
66+
" v{} (py{})".format(ver, pyver)
67+
for ver, pyver in versions
68+
)
69+
70+
return " v" + versions[0][0]
71+
5172
def show_quick_panel_st3(self, libraries):
5273
items = [
53-
[info["name"] + " v" + info["releases"][0]["version"], info["description"]]
74+
[info["name"] + self.latest_releases(info["releases"]), info["description"]]
5475
for info in libraries
5576
]
5677

@@ -63,11 +84,13 @@ def on_done(picked):
6384
)
6485

6586
def show_quick_panel_st4(self, libraries):
66-
# TODO: display supported python versions
67-
6887
items = []
6988
for info in libraries:
70-
display_name = info["name"] + " v" + info["releases"][0]["version"]
89+
versions = self.latest_releases(info["releases"])
90+
if not versions:
91+
continue
92+
93+
display_name = info["name"] + versions
7194

7295
details = [html.escape(info["description"])]
7396

0 commit comments

Comments
 (0)