diff --git a/package_control/commands/install_package_command.py b/package_control/commands/install_package_command.py index 4f8489e1..d10b4018 100644 --- a/package_control/commands/install_package_command.py +++ b/package_control/commands/install_package_command.py @@ -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 @@ -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) @@ -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 @@ -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), diff --git a/package_control/package_tasks.py b/package_control/package_tasks.py index 23d165bf..b575b454 100644 --- a/package_control/package_tasks.py +++ b/package_control/package_tasks.py @@ -100,6 +100,11 @@ class PackageTaskRunner(PackageDisabler): Overwrite existing unmanaged packages. """ + ENABLE = 'enable' + """ + Enable existing managed packages. + """ + PULL = 'pull' """ Upgrade unmanaged vcs packages. @@ -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) @@ -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')