| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d6bb347 commit da2a126
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,8 @@ | |||
| 4 | 4 | and return None, or a tuple of the start index, end index, and the word""" | |
| 5 | 5 | ||
| 6 | 6 | import re | |
| 7 | + from itertools import chain | ||
| 8 | + | ||
| 7 | 9 | ||
| 8 | 10 | current_word_re = re.compile(r'[\w_][\w0-9._]*[(]?') | |
| 9 | 11 | current_dict_key_re = re.compile(r'''[\w_][\w0-9._]*\[([\w0-9._(), '"]*)''') | |
@@ -89,8 +91,9 @@ def current_object_attribute(cursor_offset, line): | |||
| 89 | 91 | match = current_word(cursor_offset, line) | |
| 90 | 92 | if match is None: return None | |
| 91 | 93 | start, end, word = match | |
| 92 | - matches = list(current_object_attribute_re.finditer(word)) | ||
| 93 | - for m in matches[1:]: | ||
| 94 | + matches = current_object_attribute_re.finditer(word) | ||
| 95 | + matches.next() | ||
| 96 | + for m in matches: | ||
| 94 | 97 | if m.start(1) + start <= cursor_offset and m.end(1) + start >= cursor_offset: | |
| 95 | 98 | return m.start(1) + start, m.end(1) + start, m.group(1) | |
| 96 | 99 | return None | |
@@ -123,8 +126,8 @@ def current_from_import_import(cursor_offset, line): | |||
| 123 | 126 | match1 = current_from_import_import_re_2.search(line[baseline.end():]) | |
| 124 | 127 | if match1 is None: | |
| 125 | 128 | return None | |
| 126 | - matches = list(current_from_import_import_re_3.finditer(line[baseline.end():])) | ||
| 127 | - for m in [match1] + matches: | ||
| 129 | + matches = current_from_import_import_re_3.finditer(line[baseline.end():]) | ||
| 130 | + for m in chain((match1, ), matches): | ||
| 128 | 131 | start = baseline.end() + m.start(1) | |
| 129 | 132 | end = baseline.end() + m.end(1) | |
| 130 | 133 | if start < cursor_offset and end >= cursor_offset: | |
@@ -139,8 +142,8 @@ def current_import(cursor_offset, line): | |||
| 139 | 142 | match1 = current_import_re_2.search(line[baseline.end():]) | |
| 140 | 143 | if match1 is None: | |
| 141 | 144 | return None | |
| 142 | - matches = list(current_import_re_3.finditer(line[baseline.end():])) | ||
| 143 | - for m in [match1] + matches: | ||
| 145 | + matches = current_import_re_3.finditer(line[baseline.end():]) | ||
| 146 | + for m in chain((match1, ), matches): | ||
| 144 | 147 | start = baseline.end() + m.start(1) | |
| 145 | 148 | end = baseline.end() + m.end(1) | |
| 146 | 149 | if start < cursor_offset and end >= cursor_offset: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments