Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve /add completion popup candidate display on long file names #3640

Open
Dima-369 opened this issue Mar 25, 2025 · 1 comment
Open

Improve /add completion popup candidate display on long file names #3640

Dima-369 opened this issue Mar 25, 2025 · 1 comment

Comments

@Dima-369
Copy link

Issue

I have a Kotlin Compose project and all source files are always displayed like this on /add which is cumbersome to use.

Image

This means, I always have to arrow through the candidates to find the matching one. Works, but not too great.

Image

Roo Code, as a comparison, displays the file names like this (just the end) which is often far more useful:

Image

Version and model info

Aider v0.78.0
Model: openrouter/deepseek/deepseek-chat:free with diff edit format, prompt cache, infinite output
Git repo: .git with 272 files
Repo-map: using 4096 tokens, auto refresh
Added memory-bank/techContext.md to the chat.

@Dima-369
Copy link
Author

Turns out that it is not that easy since that functionality is from the prompt_toolkit library. Locally, if I patch its menus.py with this function:

def _trim_formatted_text(
    formatted_text: StyleAndTextTuples, max_width: int
) -> tuple[StyleAndTextTuples, int]:
    """
    Trim the text to `max_width`, prepend dots when the text is too long.
    Returns (text, width) tuple.
    """
    width = fragment_list_width(formatted_text)

    # When the text is too wide, trim it.
    if width > max_width:
        result = []  # Text fragments.
        remaining_width = max_width - 3  # Reserve space for "..."
        fragments = list(explode_text_fragments(formatted_text))
        
        # Start from the end and work backwards
        for style_and_ch in reversed(fragments):
            ch_width = get_cwidth(style_and_ch[1])
            
            if ch_width <= remaining_width:
                result.insert(0, style_and_ch)  # Insert at start to maintain order
                remaining_width -= ch_width
            else:
                break
                
        result.insert(0, ("", "..."))  # Prepend the dots
        
        return result, max_width - remaining_width
    else:
        return formatted_text, width

I get this display, which is exactly what I like. One can also patch column width to be a bit nicer when the paths are so long (maybe maxing out at 2 columns), but this is good for the start.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant