mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
aider: Added trailing directory delimiter to common_prefix in get_input function.
# Context: USER: os.path.commonprefix doesn't respect file path dir boundaries. I want to find the common_prefix of the nearest parent directory, which commonpath does. but i also want common_prefix to include the final trailing directory delimeter ASSISTANT: To achieve this, you can use `os.path.commonpath` to find the common path and then add the trailing directory delimiter if it's not already present. Here's the change you need to make in the `get_input` function: ```python aider/getinput.py <<<<<<< ORIGINAL if len(fnames) > 1: common_prefix = os.path.commonpath(fnames) ======= if len(fnames) > 1: common_prefix = os.path.commonpath(fnames) if not common_prefix.endswith(os.path.sep): common_prefix += os.path.sep >>>>>>> UPDATED ```
This commit is contained in:
parent
1408a8edc9
commit
7d1d2d14a6
1 changed files with 3 additions and 1 deletions
|
@ -58,7 +58,9 @@ def get_input(history_file, fnames, commands):
|
|||
|
||||
fnames = list(fnames)
|
||||
if len(fnames) > 1:
|
||||
common_prefix = os.path.commonprefix(fnames)
|
||||
common_prefix = os.path.commonpath(fnames)
|
||||
if not common_prefix.endswith(os.path.sep):
|
||||
common_prefix += os.path.sep
|
||||
short_fnames = [fname.replace(common_prefix, "", 1) for fname in fnames]
|
||||
else:
|
||||
short_fnames = [os.path.basename(fnames[0])]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue