Skip to content

Commit ea10d10

Browse files
committed
Bug fix regarding empty Definition parameter lists
1 parent 8e1c910 commit ea10d10

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
- fixed a nasty bug in the argument queries, which prevented above/below queries to select parts of calls inside with clauses and for loops( it did not affect counting though)
1919

20+
- fixed a bug regarding empty definition parameter lists, where the initial "def" keyword would be selected. Now the cursor is correct placed between the empty brackets
21+
2022
- documentation fix, the documentation for the same keyword was pointing to the unofficial small regions of interest
2123

2224
### Changed

library/info.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,8 @@ def fix_definition(root,atok):
989989
token = root.first_token
990990
token = atok.find_token(token,tokenize.NAME,"def")
991991
token = next_token(atok,token )
992+
993+
name_token = token
992994
if match_node(root,ast.FunctionDef):
993995
fake_node = create_fake(root,ast.Name,real_tokens = token,
994996
parent = root,parent_field = "name",
@@ -1025,6 +1027,10 @@ def fix_definition(root,atok):
10251027
if temporary:
10261028
x.first_token = temporary[0]
10271029
x.last_token = temporary[-1]
1030+
else:
1031+
token = next_token(atok,name_token)
1032+
x.first_token = x.last_token = asttokens.Token(0,"",(token.start[0],token.start[1]+1),(token.start[0],token.start[1]+1),"",
1033+
token.index,token.startpos+1,token.startpos+1)
10281034
mark_fixed(root)
10291035
return True
10301036

0 commit comments

Comments
 (0)