Skip to content

Commit

Permalink
Commands: fix: filter out already selected tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azizk committed Aug 13, 2023
1 parent 5c46aca commit 54e189e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions commands/mix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 10 additions & 0 deletions commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down

0 comments on commit 54e189e

Please sign in to comment.