Skip to content

Commit a60ce5b

Browse files
committed
Complete parameters without input
1 parent 7bf93f5 commit a60ce5b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

bpython/autocomplete.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,12 @@ def matches(
604604
return matches if matches else None
605605

606606
def locate(self, cursor_offset: int, line: str) -> Optional[LinePart]:
607-
return lineparts.current_word(cursor_offset, line)
607+
r = lineparts.current_word(cursor_offset, line)
608+
if r and r.word[-1] == "(":
609+
# if the word ends with a (, it's the parent word with an empty
610+
# param. Return an empty word
611+
return lineparts.LinePart(r.stop, r.stop, "")
612+
return r
608613

609614

610615
class ExpressionAttributeCompletion(AttrCompletion):

bpython/test/test_autocomplete.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,3 +435,6 @@ def func(apple, apricot, banana, carrot):
435435
self.assertSetEqual(
436436
com.matches(3, "car", funcprops=funcspec), {"carrot="}
437437
)
438+
self.assertSetEqual(
439+
com.matches(5, "func(", funcprops=funcspec), {"apple=", "apricot=", "banana=", "carrot="}
440+
)

0 commit comments

Comments
 (0)