Skip to content

Commit 2861fc7

Browse files
committed
Fix problem with not checking None values in a nearest_node_from_offset
relevant to their factoring going on due to #19 The loop was not checking if the token produced is None which caused problems when the cursor Was at the beginning of the file in an empty line
1 parent cb0fb87 commit 2861fc7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/selection_node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ def nearest_node_from_offset(root,atok,offset,special=False):
1111
converter = atok._line_numbers
1212
original_token = atok.get_token_from_offset(offset)
1313
token = original_token
14-
while token.string.isspace() or not token.string:
14+
while token and (not token.string or token.string.isspace()):
1515
token = previous_token(atok,token)
16-
if converter.offset_to_line(offset)[0] != converter.offset_to_line(token.startpos)[0]:
16+
if not token or converter.offset_to_line(offset)[0] != converter.offset_to_line(token.startpos)[0]:
1717
following = next_token(atok,original_token)
1818
while following and following.string.isspace():
1919
token = following

0 commit comments

Comments
 (0)