Skip to content

Commit

Permalink
Backup and reset settings once before disabling packages
Browse files Browse the repository at this point in the history
This commit moves call of `backup_and_reset_settings` method to make it called
once for all affected packages.
  • Loading branch information
deathaxe committed Sep 8, 2024
1 parent c17c061 commit 8b22243
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions package_control/package_disabler.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ def disable_packages(package_actions):

# Derermine whether to Backup old color schemes, syntaxes and theme for later restore.
# If False, reset to defaults only.
backup = action in (PackageDisabler.INSTALL, PackageDisabler.UPGRADE)
need_restore |= backup
PackageDisabler.backup_and_reset_settings(disabled, backup)
need_restore |= action in (PackageDisabler.INSTALL, PackageDisabler.UPGRADE)

if action == PackageDisabler.UPGRADE:
for package in disabled:
Expand All @@ -284,11 +282,7 @@ def disable_packages(package_actions):
version = PackageDisabler.get_version(package)
events.add(events.REMOVE, package, version)

if need_restore:
if PackageDisabler.refcount == 0:
PackageDisabler.disable_indexer()

PackageDisabler.refcount += 1
PackageDisabler.backup_and_reset_settings(affected, need_restore)

save_list_setting(
pc_settings,
Expand Down Expand Up @@ -439,6 +433,12 @@ def backup_and_reset_settings(packages, backup):
settings = sublime.load_settings(preferences_filename())
cached_settings = {}

if backup:
if PackageDisabler.refcount == 0:
PackageDisabler.disable_indexer()

PackageDisabler.refcount += 1

# Backup and reset global theme(s)
for key, default_file in PackageDisabler.default_themes.items():
theme_file = settings.get(key)
Expand Down

0 comments on commit 8b22243

Please sign in to comment.