Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86428d0
commit 58a41aa
Showing
2 changed files
with
15 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
def get_scopes(view, start_at_position, stop_at_position): | ||
"""Return the unique scopes in the view between start_at_position and stop_at_position, in the order in which they occur.""" | ||
current_scope = None | ||
for pos in range(start_at_position, stop_at_position): | ||
scope = view.scope_name(pos) | ||
if current_scope is None: | ||
current_scope = (scope, pos, pos) | ||
elif current_scope[0] == scope: # if the current scope is exactly the same, extend it | ||
current_scope = (current_scope[0], current_scope[1], pos) | ||
else: # the previous scope is complete, register new one | ||
yield current_scope | ||
current_scope = (scope, pos, pos) | ||
if current_scope is not None: | ||
yield current_scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters