From 169020729527682e6f579b521be92ddd4fe10f8d Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Thu, 4 Nov 2021 21:09:02 +0200 Subject: [PATCH 1/2] Fix syntax definition automatic assignment for syntax test files --- plugins/syntaxtest_dev.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/syntaxtest_dev.py b/plugins/syntaxtest_dev.py index 176f3ccb..de2aee56 100644 --- a/plugins/syntaxtest_dev.py +++ b/plugins/syntaxtest_dev.py @@ -428,6 +428,13 @@ class AssignSyntaxTestSyntaxListener(sublime_plugin.EventListener): PLAIN_TEXT = "Packages/Text/Plain text.tmLanguage" def on_load(self, view): + if view.size() == 0 and view.file_name().startswith(sublime.packages_path() + '/'): + sublime.set_timeout(lambda: self.assign_syntax(view), 100) + return + + self.assign_syntax(view) + + def assign_syntax(self, view): test_header = get_syntax_test_tokens(view) if not test_header: return @@ -447,7 +454,7 @@ def on_load(self, view): view.assign_syntax(self.PLAIN_TEXT) # just base name specified - elif not current_syntax.endswith(test_syntax): + elif not current_syntax.endswith('/' + test_syntax): syntax_candidates = sublime.find_resources(test_syntax) if syntax_candidates: logger.debug("Found the following candidates for %r: %r", From 833599887867c16db55b683e76a00c431f5cdad9 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Thu, 18 Nov 2021 21:40:11 +0200 Subject: [PATCH 2/2] change from early return to an else in the EventListener on_load --- plugins/syntaxtest_dev.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/syntaxtest_dev.py b/plugins/syntaxtest_dev.py index de2aee56..a4945420 100644 --- a/plugins/syntaxtest_dev.py +++ b/plugins/syntaxtest_dev.py @@ -430,9 +430,8 @@ class AssignSyntaxTestSyntaxListener(sublime_plugin.EventListener): def on_load(self, view): if view.size() == 0 and view.file_name().startswith(sublime.packages_path() + '/'): sublime.set_timeout(lambda: self.assign_syntax(view), 100) - return - - self.assign_syntax(view) + else: + self.assign_syntax(view) def assign_syntax(self, view): test_header = get_syntax_test_tokens(view)