fix: resolve short color_scheme paths using find_resources#36
Open
gadflysu wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
color_schemein Preferences is a bare filename (e.g.ayu-dark.sublime-color-scheme) — which is what Sublime Text writes when the user selects a scheme via the Command Palette — the plugin blindly prefixes it withPackages/Color Scheme - Default/. This path is wrong for any third-party theme, resulting inOSError: resource "Packages/Color Scheme - Default/ayu-dark.sublime-color-scheme" not found.Fix
Use
sublime.find_resources(filename)to let Sublime Text locate the file across all installed packages. Prefer results outsidePackages/User/since plugins such as SFTP and RainbowBrackets copy the active color scheme there and we want the canonical source. Fall back to the original prefix only when no match is found.Related
Closes #22
Closes #30
Related to #9 (now closed, same root cause)