From 59e664e220ebe34e49063e409de19d22abfe2ebc Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 9 May 2023 09:20:58 -0700 Subject: [PATCH] Connect `FileContentCompleter` to `prompt()` call in `get_input()` for autocompletion.` # Context: USER: connect the filecontentcompleter to the prompt() call in get_input, so that it autocompletes ASSISTANT: To connect the `FileContentCompleter` to the `prompt()` call in the `get_input` method, you need to pass the `FileContentCompleter` instance as the `completer` argument in the `prompt()` function. Here's the change: ```python coder.py <<<<<<< ORIGINAL if multiline_input: line = prompt(". ") else: line = prompt("> ") ======= completer_instance = FileContentCompleter(self.fnames) if multiline_input: line = prompt(". ", completer=completer_instance) else: line = prompt("> ", completer=completer_instance) >>>>>>> UPDATED ``` This change will enable autocompletion using the `FileContentCompleter` when you call `prompt()`. --- coder.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/coder.py b/coder.py index 6519a5897..c5a2b9c1f 100755 --- a/coder.py +++ b/coder.py @@ -156,10 +156,11 @@ class Coder: while True: try: - if multiline_input: - line = prompt(". ") - else: - line = prompt("> ") + completer_instance = FileContentCompleter(self.fnames) + if multiline_input: + line = prompt(". ", completer=completer_instance) + else: + line = prompt("> ", completer=completer_instance) except EOFError: return if line.strip() == "{" and not multiline_input: