Skip to content

Commit db6c9bd

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

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,3 +435,7 @@ 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),
440+
{"apple=", "apricot=", "banana=", "carrot="},
441+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy