-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
9 changed files
with
146 additions
and
137 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
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,49 @@ | ||
import re | ||
|
||
|
||
def check_scope(current_scope, target_scopes): | ||
valid = True | ||
for target_scope in target_scopes: | ||
if not re.search(target_scope, current_scope): | ||
valid = False | ||
break | ||
return valid | ||
|
||
|
||
def check_line_matches(line_text, target_parts): | ||
valid = True | ||
for target_part in target_parts: | ||
if not re.search(target_part, line_text): | ||
valid = False | ||
break | ||
return valid | ||
|
||
|
||
def check(view, spell): | ||
valid = True | ||
|
||
for sel in view.sel(): | ||
line = view.line(sel.a) | ||
line_text = view.substr(line) | ||
view_scope = view.scope_name(sel.a) | ||
|
||
context = spell.get('context', {'scope': [], 'line_matches': []}) | ||
spell_scope = context.get('scope', []) | ||
line_matches = context.get('line_matches', []) | ||
values = spell.get('args', {'values': None}).get('values', None) | ||
|
||
if values: | ||
escaped_values = [re.escape(val) for val in values] | ||
line_matches.append('(' + '|'.join(escaped_values) + ')') | ||
|
||
valid = check_scope(view_scope, spell_scope) | ||
|
||
if not valid: | ||
break | ||
|
||
valid = check_line_matches(line_text, line_matches) | ||
|
||
if not valid: | ||
break | ||
|
||
return valid |
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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,27 @@ | ||
import sublime | ||
|
||
|
||
def find_previous_delimiter(view, line, re_delimiter, start): | ||
found = None | ||
|
||
while start > line.a and start > 0: | ||
region = sublime.Region(start - 1, start) | ||
if re_delimiter.match(view.substr(region)): | ||
found = start | ||
break | ||
start -= 1 | ||
|
||
return found | ||
|
||
|
||
def find_next_delimiter(view, line, re_delimiter, delimiter_length, start): | ||
found = None | ||
|
||
while start < line.b and start < 999999: | ||
region = sublime.Region(start, start + delimiter_length) | ||
if re_delimiter.match(view.substr(region)): | ||
found = start | ||
break | ||
start += 1 | ||
|
||
return found |