From b8d2a18829245b8d915828ae36ee4ee1ceb7e554 Mon Sep 17 00:00:00 2001 From: Yorick van Pelt Date: Sun, 20 Apr 2025 12:03:53 +0200 Subject: [PATCH] Use click.visible_prompt_func directly instead of prompt() to fix editing issues click.prompt() was manually printing the prompt characters, confusing readline. This was noticable when using ctrl+backspace or when wrapping a line. --- llm/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/llm/cli.py b/llm/cli.py index a4c35e72..b42dcb9c 100644 --- a/llm/cli.py +++ b/llm/cli.py @@ -909,7 +909,11 @@ def chat( accumulated = [] end_token = "!end" while True: - prompt = click.prompt("", prompt_suffix="> " if not in_multi else "") + prompt = "" + while prompt == "" or prompt.isspace(): + # use click.termui.visible_prompt_func (overridden during tests) directly + # to avoid bug in click.prompt + prompt = click.termui.visible_prompt_func("> " if not in_multi else "") if prompt.strip().startswith("!multi"): in_multi = True bits = prompt.strip().split()