mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
cleaned up filehistory
This commit is contained in:
parent
1b28d24874
commit
8c88d0fca8
1 changed files with 11 additions and 18 deletions
29
coder.py
29
coder.py
|
@ -9,7 +9,7 @@ from prompt_toolkit.completion import Completer, Completion
|
||||||
from prompt_toolkit.history import FileHistory
|
from prompt_toolkit.history import FileHistory
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.prompt import Confirm, Prompt
|
from rich.prompt import Confirm, Prompt
|
||||||
from colorama import Fore, Style
|
from colorama import Style
|
||||||
from rich.live import Live
|
from rich.live import Live
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
from rich.markdown import Markdown
|
from rich.markdown import Markdown
|
||||||
|
@ -46,17 +46,14 @@ class FileContentCompleter(Completer):
|
||||||
if word.startswith(last_word):
|
if word.startswith(last_word):
|
||||||
yield Completion(word, start_position=-len(last_word))
|
yield Completion(word, start_position=-len(last_word))
|
||||||
|
|
||||||
|
|
||||||
class Coder:
|
class Coder:
|
||||||
fnames = dict()
|
fnames = dict()
|
||||||
last_modified = 0
|
last_modified = 0
|
||||||
repo = None
|
repo = None
|
||||||
|
|
||||||
def __init__(self, main_model, files, pretty, history_file=".coder.history"):
|
def __init__(self, main_model, files, pretty, history_file=".coder.history"):
|
||||||
self.history_file = history_file
|
self.history_file = history_file
|
||||||
try:
|
|
||||||
#readline.read_history_file(self.history_file)
|
|
||||||
pass
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if pretty:
|
if pretty:
|
||||||
self.console = Console()
|
self.console = Console()
|
||||||
|
@ -150,18 +147,19 @@ class Coder:
|
||||||
|
|
||||||
inp = ""
|
inp = ""
|
||||||
multiline_input = False
|
multiline_input = False
|
||||||
if self.pretty:
|
|
||||||
print(Fore.GREEN, end="\r")
|
|
||||||
else:
|
|
||||||
print()
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
completer_instance = FileContentCompleter(self.fnames)
|
completer_instance = FileContentCompleter(self.fnames)
|
||||||
if multiline_input:
|
if multiline_input:
|
||||||
line = prompt(". ", completer=completer_instance, history=FileHistory(self.history_file))
|
show = ". "
|
||||||
else:
|
else:
|
||||||
line = prompt("> ", completer=completer_instance, history=FileHistory(self.history_file))
|
show = "> "
|
||||||
|
line = prompt(
|
||||||
|
show,
|
||||||
|
completer=completer_instance,
|
||||||
|
history=FileHistory(self.history_file),
|
||||||
|
)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
return
|
return
|
||||||
if line.strip() == "{" and not multiline_input:
|
if line.strip() == "{" and not multiline_input:
|
||||||
|
@ -175,12 +173,7 @@ class Coder:
|
||||||
inp = line
|
inp = line
|
||||||
break
|
break
|
||||||
|
|
||||||
if self.pretty:
|
print()
|
||||||
print(Style.RESET_ALL)
|
|
||||||
else:
|
|
||||||
print()
|
|
||||||
|
|
||||||
#readline.write_history_file(self.history_file)
|
|
||||||
return inp
|
return inp
|
||||||
|
|
||||||
def get_last_modified(self):
|
def get_last_modified(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue