diff options
Diffstat (limited to 'apps/Sublime Text 4')
-rw-r--r-- | apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap | 8 | ||||
-rw-r--r-- | apps/Sublime Text 4/Packages/User/HSMusic Editing.py | 18 |
2 files changed, 26 insertions, 0 deletions
diff --git a/apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap b/apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap index 551ebaf..82f169c 100644 --- a/apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap +++ b/apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap @@ -41,4 +41,12 @@ { "key": "project_name", "operator": "regex_contains", "operand": "HSMusic" }, ], }, + + { "keys": ["enter"], + "command": "exit_wiki_tag", + "context": [ + { "key": "project_name", "operator": "regex_contains", "operand": "HSMusic" }, + { "key": "panel_has_focus", "operator": "not_equal" }, + ], + }, ] diff --git a/apps/Sublime Text 4/Packages/User/HSMusic Editing.py b/apps/Sublime Text 4/Packages/User/HSMusic Editing.py index 4fa3663..fcf4592 100644 --- a/apps/Sublime Text 4/Packages/User/HSMusic Editing.py +++ b/apps/Sublime Text 4/Packages/User/HSMusic Editing.py @@ -61,9 +61,15 @@ class _CursorAdaptiveCommand(sublime_plugin.TextCommand): real_regions = list() for (region, direction, delta, backoff) in new_regions: if direction in ['collapse-left', 'collapse-right']: + # Adding a `delta` hasn't been particularly tested with multiple cursors at once. point = _normalize_region(region).a align_direction = ('right' if direction == 'collapse-left' else 'left') aligned_point = self.__align_point_after_insertions(point, align_direction) + if delta: + if direction == 'collapse-right': + aligned_point += delta + else: + aligned_point -= delta real_regions.append(aligned_point) elif direction in ['left', 'right']: start = region.a @@ -96,6 +102,9 @@ class _CursorAdaptiveCommand(sublime_plugin.TextCommand): def perform_move(self, edit, region, delta): return (region, 'right', delta, 0) + def perform_collapse_move(self, edit, region, delta): + return (region, 'collapse-right', delta, 0) + def perform_insert(self, edit, region, direction, insert, backoff): insert_point = region.b aligned_insert_point = self.__align_point_after_insertions(insert_point, direction) @@ -202,6 +211,15 @@ class EnterExitWikiTagCommand(_CursorAdaptiveCommand): else: return ('wrap', '[[', ']]', 'left') +class ExitWikiTagCommand(_CursorAdaptiveCommand): + def handle_region(self, region): + rest_of_tag = _match_rest_of_tag_in_progress(self.view, region) + if rest_of_tag: + return ('collapse_move', len(rest_of_tag)) + + def no_action_fallback(self, edit): + self.view.run_command('insert', {'characters': '\n'}) + class HyphenInWikiTagCommand(_CursorAdaptiveCommand): ref_cycle = ['artist', 'group', 'flash', 'tag'] |