restore settings backup function
@@ -14,10 +14,30 @@ from .lint.const import WARN_ERR, STATUS_KEY
from .panel import panel
+def backup_old_settings(usr_dir_abs):
+ """
+ If user settings file in old format exists it is renamed to disable it
+ and back it up.
+ A message will be displayed to the user.
+ """
+ msg = """SublimeLinter\n\nYour settings have been backed up to:\nSublimeLinter (old).sublime-settings\nin Packages/User/""" # noqa: 501
+ settings_file = os.path.join(usr_dir_abs, "SublimeLinter.sublime-settings")
+ if os.path.exists(settings_file):
+ path = "Packages/User/SublimeLinter.sublime-settings"
+ settings = sublime.decode_value(sublime.load_resource(path))
+
+ if "user" in settings:
+ new_name = "SublimeLinter (old).sublime-settings"
+ new_path = os.path.join(usr_dir_abs, new_name)
+ os.rename(settings_file, new_path)
+ sublime.message_dialog(msg)
+
+
def plugin_loaded():
"""Entry point for SL plugins."""
persist.plugin_is_loaded = True
+ backup_old_settings(os.path.join(sublime.packages_path(), "User"))
persist.settings.load()
style.StyleParser()()
