From 0b1581b73bff34d2b7b1360003d9dbc4ae41565b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 23 Jan 2024 17:07:24 -0400 Subject: st4: hsmusic: fix space handling outside of tags --- apps/Sublime Text 4/Packages/User/HSMusic Editing.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/Sublime Text 4/Packages/User/HSMusic Editing.py b/apps/Sublime Text 4/Packages/User/HSMusic Editing.py index bde61b0..89fa031 100644 --- a/apps/Sublime Text 4/Packages/User/HSMusic Editing.py +++ b/apps/Sublime Text 4/Packages/User/HSMusic Editing.py @@ -43,7 +43,11 @@ class _CursorAdaptiveCommand(sublime_plugin.TextCommand): actions = list() for region in self.view.sel(): action = self.handle_region(region) - actions.append((region, *(action or self.handle_region_fallback))) + if action: + actions.append((region, *(action or self.handle_region_fallback))) + + if not actions: + return self.no_action_fallback(edit) new_regions = list() for (region, action, *args) in actions: @@ -90,6 +94,9 @@ class _CursorAdaptiveCommand(sublime_plugin.TextCommand): def handle_region(self, region): pass + def no_action_fallback(self, edit): + pass + def perform_keep(self, edit, region): return (region, 'right', 0, 0) @@ -224,3 +231,6 @@ class SpaceInWikiTagCommand(_CursorAdaptiveCommand): return ('move', 1) else: return ('insert', 'right', '|', 0) + + def no_action_fallback(self, edit): + self.view.run_command('insert', {'characters': ' '}) -- cgit 1.3.0-6-gf8a5