diff --git a/commands/mix_test.py b/commands/mix_test.py index 9efce451..ddc28ca6 100644 --- a/commands/mix_test.py +++ b/commands/mix_test.py @@ -94,6 +94,12 @@ def run(self, _edit): if regions[-1].intersects(selected_lines_region) ] + unique_intersecting_test_tuples = \ + unique_items([tuple(r.to_tuple() for r in regions) for regions in intersecting_test_regions]) + + intersecting_test_regions = \ + [tuple(sublime.Region(*t) for t in tuples) for tuples in unique_intersecting_test_tuples] + grouped_isecting_by_describe_dict, test_to_describe_dict = \ group_by_describe_block_regions(intersecting_test_regions) diff --git a/commands/utils.py b/commands/utils.py index de07345a..6606e3a5 100644 --- a/commands/utils.py +++ b/commands/utils.py @@ -18,6 +18,16 @@ def print_status_msg(msg): print(PRINT_PREFIX, msg) sublime.status_message(PRINT_PREFIX + ' ' + msg) +def unique_items(items): + unique_items, seen_items = [], set() + + for item in items: + if item not in seen_items: + unique_items.append(item) + seen_items.add(item) + + return unique_items + def expand_scope_right(view, begin_point, scope): end_point = next( (pt for pt in range(begin_point, view.size()) if not view.match_selector(pt, scope)),