« get me outta code hell

st4: hsmusic: simplify collapse-left/right into one - dotfiles - Miscellaneous configuration files of my personal use
about summary refs log tree commit diff
path: root/apps/Sublime Text 4/Packages/User/HSMusic Editing.py
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-23 17:15:09 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-23 17:15:09 -0400
commitacbb2f3282a25626316428769502105f7a86986d (patch)
tree2d2f4249467680fbbbdcbbb6c5a5207e396d840c /apps/Sublime Text 4/Packages/User/HSMusic Editing.py
parent5894d2d244cc52bb9756d3e0215bf09ab25f8139 (diff)
st4: hsmusic: simplify collapse-left/right into one
Diffstat (limited to 'apps/Sublime Text 4/Packages/User/HSMusic Editing.py')
-rw-r--r--apps/Sublime Text 4/Packages/User/HSMusic Editing.py17
1 files changed, 5 insertions, 12 deletions
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