From e4e6751ccfb3f43af4cc0d7aedb67bfdc0213342 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 27 Oct 2024 10:40:27 +0100 Subject: [PATCH 1/2] Remove obsolete version checks --- plugins/settings/known_settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/settings/known_settings.py b/plugins/settings/known_settings.py index 1a78a722..67149bc8 100644 --- a/plugins/settings/known_settings.py +++ b/plugins/settings/known_settings.py @@ -712,7 +712,7 @@ def _color_scheme_completions(key, default): - trigger (string): base file name of the color scheme - contents (string): the value to commit to the settings """ - if int(sublime.version()) >= 4095 and key == 'color_scheme': + if key == 'color_scheme': yield format_completion_item(value="auto", annotation="dark-/light switching") hidden = get_setting('settings.exclude_color_scheme_patterns') or [] @@ -771,7 +771,7 @@ def _theme_completions(key, default): - contents (string): the file name to commit to the settings """ hidden = get_setting('settings.exclude_theme_patterns') or [] - if int(sublime.version()) >= 4095 and key == 'theme': + if key == 'theme': yield format_completion_item(value="auto", annotation="dark-/light switching") for theme_path in ResourcePath.glob_resources("*.sublime-theme"): if not any(hide in theme_path.name for hide in hidden): From 9091de9637b7775154c15448a4c19bee50ce7c45 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 27 Oct 2024 10:40:45 +0100 Subject: [PATCH 2/2] Remove obsolete XML extension override hotfix --- plugins/__init__.py | 6 -- plugins/xml_hidden_extensions_hotfix.py | 79 ------------------------- 2 files changed, 85 deletions(-) delete mode 100644 plugins/xml_hidden_extensions_hotfix.py diff --git a/plugins/__init__.py b/plugins/__init__.py index e11b679d..188f254f 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -14,12 +14,6 @@ from .syntaxtest_dev import * # noqa from .theme_dev import * # noqa -from . import xml_hidden_extensions_hotfix - - -def plugin_loaded(): - xml_hidden_extensions_hotfix.plugin_loaded() - def _is_plugin_class(obj): if hasattr(obj, '__bases__'): diff --git a/plugins/xml_hidden_extensions_hotfix.py b/plugins/xml_hidden_extensions_hotfix.py deleted file mode 100644 index f002f077..00000000 --- a/plugins/xml_hidden_extensions_hotfix.py +++ /dev/null @@ -1,79 +0,0 @@ -"""Bootstrap the 'hidden_extensions' setting for the XML syntax. - -The XML package includes a `XML.sublime-settings` file -that sets `hidden_extensions` to include some of the extensions -we want to highlight with our package. -There is currently no other way to override this, -so we manually override this extension list -in a User settings file with a plugin. - -See also: - https://github.com/sublimehq/Packages/issues/823 - https://github.com/SublimeTextIssues/Core/issues/1326 -""" -import sublime -from sublime_lib import ResourcePath - -__all__ = [ - "plugin_loaded", -] - -DEFAULT_VALUE = ["rss", "sublime-snippet", "vcproj", "tmLanguage", "tmTheme", "tmSnippet", - "tmPreferences", "dae"] -MODIFIED_VALUE = ["rss", "vcproj", "tmLanguage", "tmTheme", "tmSnippet", "dae"] - -# Encode ST build and date of last change (of this file) into the bootstrap value. -# I'm not sure what exactly I'm gonna do with it, so just include info I might find useful later. -BOOTSTRAP_VALUE = [3126, 2017, 3, 13] - - -def override_extensions(expected, modified): - settings = sublime.load_settings("XML.sublime-settings") - - if settings.get('hidden_extensions') == expected: - settings.set('hidden_extensions', modified) - settings.set('package_dev.bootstrapped', BOOTSTRAP_VALUE) - sublime.save_settings("XML.sublime-settings") - - print("[PackageDev] Bootstrapped XML's `hidden_extensions` setting") - - -def remove_override(): - settings = sublime.load_settings("XML.sublime-settings") - if settings.get('package_dev.bootstrapped'): - settings.erase('package_dev.bootstrapped') - - if settings.get('hidden_extensions') == MODIFIED_VALUE: - settings.erase('hidden_extensions') - print("[PackageDev] Unbootstrapped XML's `hidden_extensions` setting") - sublime.save_settings("XML.sublime-settings") - sublime.set_timeout(remove_file_if_empty, 2000) # Give ST time to write the file - - -def remove_file_if_empty(): - path = ResourcePath("Packages/User/XML.sublime-settings").file_path() - try: - with path.open() as f: - data = sublime.decode_value(f.read()) - except (FileNotFoundError, ValueError): - pass - else: - if not data or len(data) == 1 and 'extensions' in data and not data['extensions']: - path.unlink() - print("[PackageDev] Removed now-empty XML.sublime-settings") - - -def plugin_loaded(): - version = int(sublime.version()) - if version < 3153: - override_extensions(DEFAULT_VALUE, MODIFIED_VALUE) - # "csproj" was added for 3153. - # https://github.com/sublimehq/Packages/commit/4a3712b7e236f8c4b443282d97bad17f68df318c - # Technically there was a change in 4050, but nobody should be using that anymore. - # https://github.com/sublimehq/Packages/commit/7866273af18398bce324408ff23c7a22f30486c8 - elif version < 4075: - override_extensions(DEFAULT_VALUE + ["csproj"], MODIFIED_VALUE + ["csproj"]) - elif version >= 4075: - # The settings were move to the syntax file - # https://github.com/sublimehq/Packages/commit/73b16ff196d3cbaf7df2cf5807fda6ab68a2434e - remove_override()