Skip to content

Commit 809a4af

Browse files
committed
fix indexing and pattern matching
1 parent e7ee0ca commit 809a4af

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pyls/plugins/importmagic_lint.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class _SourceReader():
2424
# Used to tokenize python source code
2525
def __init__(self, source):
26-
self.lines = re.findall(r'[^\n]*\n', source)
26+
self.lines = re.findall(r'[^\n]*\n?', source)
2727
# To pop lines later
2828
self.lines.reverse()
2929

@@ -118,12 +118,12 @@ def _search_symbol(source, symbol):
118118
if source_tokens_str[i:i+symbol_len] == symbol_tokens_str:
119119
location_range = {
120120
'start': {
121-
'line': source_tokens[2][0] - 1,
122-
'character': source_tokens[2][1],
121+
'line': source_tokens[i][2][0] - 1,
122+
'character': source_tokens[i][2][1],
123123
},
124124
'end': {
125-
'line': source_tokens[3][0] - 1,
126-
'character': source_tokens[3][1],
125+
'line': source_tokens[i + symbol_len - 1][3][0] - 1,
126+
'character': source_tokens[i + symbol_len - 1][3][1],
127127
}
128128
}
129129
locations.append(location_range)

0 commit comments

Comments
 (0)