Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions package_control/commands/install_package_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
from ..activity_indicator import ActivityIndicator
from ..console_write import console_write
from ..package_tasks import PackageTaskRunner
from ..settings import (
preferences_filename,
load_list_setting,
)
from ..show_error import show_message


Expand All @@ -20,9 +24,16 @@ def run(self):

def show_quick_panel():
installer = PackageTaskRunner()
installed = installer.manager.installed_packages()
settings = sublime.load_settings(preferences_filename())
disabled = installed & load_list_setting(settings, 'ignored_packages')

with ActivityIndicator('Loading packages...') as progress:
tasks = installer.create_package_tasks(actions=(installer.INSTALL, installer.OVERWRITE))
tasks = installer.create_package_tasks(actions=(
installer.INSTALL, installer.OVERWRITE, installer.REINSTALL,
installer.UPGRADE, installer.DOWNGRADE
)
)
if not tasks:
message = 'There are no packages available for installation'
console_write(message)
Expand All @@ -37,6 +48,11 @@ def show_quick_panel():
)
return

for task in tasks:
if task.action in (installer.REINSTALL, installer.UPGRADE, installer.DOWNGRADE):
if task.package_name in disabled:
task.action = installer.ENABLE

def on_done(picked):
if picked == -1:
return
Expand All @@ -45,7 +61,11 @@ def worker(task):
with ActivityIndicator('Installing package %s' % task.package_name) as progress:
installer.run_install_tasks([task], progress)

threading.Thread(target=worker, args=[tasks[picked]]).start()
task = tasks[picked]
if task.action == installer.ENABLE:
sublime.run_command("enable_packages", {"packages": [task.package_name]})
else:
threading.Thread(target=worker, args=[task]).start()

sublime.active_window().show_quick_panel(
installer.render_quick_panel_items(tasks),
Expand Down
9 changes: 7 additions & 2 deletions package_control/package_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class PackageTaskRunner(PackageDisabler):
Overwrite existing unmanaged packages.
"""

ENABLE = 'enable'
"""
Enable existing managed packages.
"""

PULL = 'pull'
"""
Upgrade unmanaged vcs packages.
Expand Down Expand Up @@ -638,7 +643,7 @@ def render_quick_panel_items(self, tasks):

for task in tasks:
action = task.action
if action == self.INSTALL or action == self.REINSTALL:
if action in (self.INSTALL, self.REINSTALL, self.ENABLE):
extra = ' v{}'.format(task.available_version)
elif action == self.DOWNGRADE or action == self.UPGRADE:
extra = ' to v{} from v{}'.format(task.available_version, task.package_version)
Expand Down Expand Up @@ -668,7 +673,7 @@ def render_quick_panel_items(self, tasks):
annotation = ''
if task.last_modified:
try:
# strip time as it is not of interrest and to be permissive with repos,
# strip time as it is not of interest and to be permissive with repos,
# which don't provide full timestamp.
date, _ = task.last_modified.split(' ', 1)
annotation = datetime.strptime(date, '%Y-%m-%d').strftime('Updated on %a %b %d, %Y')
Expand Down