From 000c91730295eccb232e45b0863a38f76c463bdd Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 10 May 2023 10:07:08 -0700 Subject: [PATCH] wip: Refactor get_input to handle single file input. --- aider/getinput.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/aider/getinput.py b/aider/getinput.py index 3d57ee4f2..c7750fd44 100644 --- a/aider/getinput.py +++ b/aider/getinput.py @@ -1,4 +1,7 @@ +import os import re +from pathlib import Path + from prompt_toolkit.styles import Style from prompt_toolkit import prompt @@ -45,11 +48,15 @@ def canned_input(show_prompt): return input_line -import os def get_input(history_file, fnames): - common_prefix = os.path.commonprefix(fnames) - short_fnames = [fname.replace(common_prefix, '', 1) for fname in fnames] + fnames = list(fnames) + if len(fnames) > 1: + common_prefix = os.path.commonprefix(fnames) + short_fnames = [fname.replace(common_prefix, '', 1) for fname in fnames] + else: + short_fnames = [Path(fnames[0]).name] + show = ' '.join(short_fnames) show += "\n> "