Add FileHistory to get_input method in Coder class.

# Context:
USER: have get_input(self): use a FileHistory with the history_file
ASSISTANT: To use a FileHistory with the history_file in the get_input(self) method, we need to import FileHistory from prompt_toolkit.history and use it when calling the prompt function. Here's the change:

```python
coder.py
<<<<<<< ORIGINAL
from prompt_toolkit import prompt
from prompt_toolkit.completion import Completer, Completion
=======
from prompt_toolkit import prompt
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.history import FileHistory
>>>>>>> UPDATED

...

class Coder:
    ...
    def get_input(self):
        ...
        while True:
            try:
                completer_instance = FileContentCompleter(self.fnames)
                if multiline_input:
                    line = prompt(". ", completer=completer_instance, history=FileHistory(self.history_file))
                else:
                    line = prompt("> ", completer=completer_instance, history=FileHistory(self.history_file))
            except EOFError:
                return
```
This change imports FileHistory and adds it as an argument to the prompt function calls in the get_input method.
This commit is contained in:
Paul Gauthier 2023-05-09 09:36:42 -07:00
parent fe222d8943
commit bc2c59368b

View file

@ -6,6 +6,7 @@ import re
import traceback
from prompt_toolkit import prompt
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.history import FileHistory
from rich.console import Console
from rich.prompt import Confirm, Prompt
from colorama import Fore, Style