From 02543c929b00019c89c204fceeb7ba82ee0d848b Mon Sep 17 00:00:00 2001 From: Isaac Muse Date: Tue, 19 Feb 2019 14:56:06 -0700 Subject: [PATCH] Fix extension compare and order of evaluation (#128) --- ApplySyntax.py | 7 ++++--- CHANGES.md | 4 ++++ docs/src/markdown/usage.md | 2 +- support.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ApplySyntax.py b/ApplySyntax.py index ec3c052..ad6a247 100755 --- a/ApplySyntax.py +++ b/ApplySyntax.py @@ -224,7 +224,7 @@ def update_extenstions(lst): ext_map = {} # Walk the entries - for entry in SETTINGS.get("default_syntaxes", []) + SETTINGS.get("syntaxes", []): + for entry in SETTINGS.get("syntaxes", []) + SETTINGS.get("default_syntaxes", []): # Grab the extensions from each relevant rule ext = [] if "extensions" in entry: @@ -544,8 +544,9 @@ def extension_matches(self, rule): extensions = rule.get('extensions', []) file_name = os.path.basename(self.file_name).lower() for extension in extensions: - dot_file_match = extension.startswith('.') and extension == file_name - if dot_file_match or file_name.endswith('.' + extension): + ext = extension.lower() + dot_file_match = ext.startswith('.') and ext == file_name + if dot_file_match or file_name.endswith('.' + ext): match = True break return match diff --git a/CHANGES.md b/CHANGES.md index 9f9335b..e1ba381 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## ApplySyntax 2.5.4 + +- **FIX**: Fix extension compare and order of evaluation. + ## ApplySyntax 2.5.3 - **FIX**: Use proper Bash syntax. diff --git a/docs/src/markdown/usage.md b/docs/src/markdown/usage.md index 468d40c..e48d1ab 100644 --- a/docs/src/markdown/usage.md +++ b/docs/src/markdown/usage.md @@ -58,7 +58,7 @@ The `extensions` attribute is used to define extensions to apply a syntax to. ` An added benefit of `extensions`, if you are using ST3 and set [`add_exts_to_lang_settings`](#add-extensions-to-language-settings) to `true`, is that ApplySyntax will add the extensions to the specified syntax language's settings file in your `User` folder. By doing this, Sublime Text will be able to show the associated icon for the file type in the sidebar. Apply syntax will also create a file `ApplySyntax.ext-list` in your `User` folder and track which extension it added so that if you remove a rule, ApplySyntax will only remove the extensions it added to the language file in question. If you do not like this functionality, you can simply disable `add_exts_to_lang_settings` by setting it to `false`. -!!! note "Note": +!!! note "Note" `add_exts_to_lang_settings` will not be applied to `extensions` found in a [project specific rule](#project-specific-rules), as project specific rules are not global, but the effects of `add_exts_to_lang_settings` are global. ### Match diff --git a/support.py b/support.py index 608d819..db696eb 100644 --- a/support.py +++ b/support.py @@ -5,7 +5,7 @@ import webbrowser import re -__version__ = "2.5.3" +__version__ = "2.5.4" __pc_name__ = 'ApplySyntax' CSS = '''