From 24b40f6982117c4e3a5fe0855b78ac7372f6a1e4 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 10 May 2023 10:04:14 -0700 Subject: [PATCH] aider: Removed common directory prefix from file paths in get_input function. # Context: USER: in get_input, instead of showing the full file paths... remove the common directory prefix that they all share ASSISTANT: To remove the common directory prefix from the file paths, we can use the `os.path.commonprefix()` function and then remove the common prefix from each file path. Here's the change: ```python aider/getinput.py <<<<<<< ORIGINAL def get_input(history_file, fnames): show = ' '.join(fnames) ======= 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] show = ' '.join(short_fnames) >>>>>>> UPDATED show += "\n> " ``` --- aider/getinput.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aider/getinput.py b/aider/getinput.py index 9db89baaa..3d57ee4f2 100644 --- a/aider/getinput.py +++ b/aider/getinput.py @@ -45,8 +45,12 @@ def canned_input(show_prompt): return input_line +import os + def get_input(history_file, fnames): - show = ' '.join(fnames) + common_prefix = os.path.commonprefix(fnames) + short_fnames = [fname.replace(common_prefix, '', 1) for fname in fnames] + show = ' '.join(short_fnames) show += "\n> " if not sys.stdin.isatty():