Skip to content

Directory completion truncated to "…/" #13108

Open

Description

@cstyles

fish version: 4.9.3
OS: macOS & Arch Linux
Terminal: WezTerm
Confirmed that the problem occurs without third-party customizations


I'm seeing a truncated completion suggestion with a directory like this:

my-project/
├── Dockerfile
└── docs/

If I try to complete docs from outside the directory, I see this:

$ ls my-project/d<TAB>
my-project/Dockerfile  …/

I expected to see this instead:

$ ls my-project/d<TAB>
my-project/Dockerfile  …/docs/

I believe the issue arises from this code:

let truncated = &full[full.len() - PREFIX_MAX_LEN..];
let (i, last_component) = truncated.split('/').enumerate().last().unwrap();
if i == 0 {
// No path separators were found in the common prefix, so we can't collapse
// any further
prefix.push_utfstr(&truncated);
} else {
// Discard any parent directories and include whats left
prefix.push('/');
prefix.push_utfstr(last_component);
}

(The directory name has to be longer than PREFIX_MAX_LEN (9) to hit the bug)

It appears that fish sees the / at the end of docs/ since it's a directory and truncates the whole thing to an ellipsis, instead of just the prefix.

I started working on a fix for this but when I ran the test suite, I discovered that this might actually be intended behavior? There's a test (added in 2f6b1ea to fix #12249) asserting that the subdirectory is fully replaced by an ellipsis:

mkdir -p clang/include
touch clang/INSTALL.txt
isolated-tmux send-keys C-u ': clang/in' Tab
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 1> : clang/include/
# CHECK: clang/INSTALL.txt …/

That felt a little strange to me so I wanted to raise the question here before opening a PR for it. Is that intended or should we change the behavior so it doesn't truncate the entire subdirectory name?

Activity

  1. faho commented on Nov 22, 2026

    @faho
    Member

    Is that intended or should we change the behavior so it doesn't truncate the entire subdirectory name?

    Nah this is clearly bogus - the last component should always be shown. Just a common issue of not correctly ignoring a trailing "/".

  2. added
    bug
    on Nov 22, 2026
  3. added this to the fish 4.10 milestone on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions