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:
Paul Gauthier 2023-05-10 12:24:09 -07:00
parent 1408a8edc9
commit 7d1d2d14a6

View file

@ -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])]