From acbb2f3282a25626316428769502105f7a86986d Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 23 Jan 2024 17:15:09 -0400 Subject: st4: hsmusic: simplify collapse-left/right into one --- apps/Sublime Text 4/Packages/User/HSMusic Editing.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'apps/Sublime Text 4/Packages/User') diff --git a/apps/Sublime Text 4/Packages/User/HSMusic Editing.py b/apps/Sublime Text 4/Packages/User/HSMusic Editing.py index 74880a2..4fa3663 100644 --- a/apps/Sublime Text 4/Packages/User/HSMusic Editing.py +++ b/apps/Sublime Text 4/Packages/User/HSMusic Editing.py @@ -60,18 +60,11 @@ class _CursorAdaptiveCommand(sublime_plugin.TextCommand): real_regions = list() for (region, direction, delta, backoff) in new_regions: - if direction == 'collapse-left': - if region.a < region.b: - point = self.__align_point_after_insertions(region.a, 'right') - else: - point = self.__align_point_after_insertions(region.b, 'right') - real_regions.append(point) - elif direction == 'collapse-right': - if region.a < region.b: - point = self.__align_point_after_insertions(region.a, 'left') - else: - point = self.__align_point_after_insertions(region.b, 'left') - real_regions.append(point) + if direction in ['collapse-left', 'collapse-right']: + point = _normalize_region(region).a + align_direction = ('right' if direction == 'collapse-left' else 'left') + aligned_point = self.__align_point_after_insertions(point, align_direction) + real_regions.append(aligned_point) elif direction in ['left', 'right']: start = region.a end = region.b + delta -- cgit 1.3.0-6-gf8a5