From 38630b78e7753236fd4092087b71bac1fda9d8fc Mon Sep 17 00:00:00 2001 From: gadflysu Date: Tue, 9 Jun 2026 12:24:33 +0800 Subject: [PATCH] fix: resolve short color_scheme paths using find_resources Previously, a bare filename like `ayu-dark.sublime-color-scheme` was blindly prefixed with `Packages/Color Scheme - Default/`, causing an OSError whenever the active scheme lives in a third-party package. Use `sublime.find_resources()` to search all installed packages, and prefer matches outside `Packages/User/` to avoid plugin-generated copies (e.g. from SFTP or RainbowBrackets). Fall back to the original prefix only when no match is found. --- colorizer.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/colorizer.py b/colorizer.py index 05cc42d..5748104 100644 --- a/colorizer.py +++ b/colorizer.py @@ -69,7 +69,18 @@ class ColorScheme(object): def __init__(self, settings): path = settings.get('color_scheme') or DEFAULT_COLOR_SCHEME if not path.startswith('Packages/'): - path = 'Packages/Color Scheme - Default/' + path + filename = os.path.basename(path) + results = sublime.find_resources(filename) + # Prefer results outside Packages/User/ — subdirs there are + # usually plugin-generated copies (sftp, RainbowBrackets, etc.) + non_user = [r for r in results if not r.startswith('Packages/User/')] + if non_user: + path = non_user[0] + elif results: + path = results[0] + else: + path = 'Packages/Color Scheme - Default/' + filename + log.debug("color_scheme resolved: %r -> %r (all: %r)" % (filename, path, results)) self.path = path[8:] self.time = datetime.datetime.now()