Skip to content

complete -C doesn't set commandline -C when running scripts #11993

@YorikSar

Description

@YorikSar

I'm running fish 4.0.8 on macOS 26.0.1.

I'm trying to implement an automated test for Fish completion for some 3rd-party tool. When I run Fish interactively, I can run source path/to/tool/share/fish/vendor_completions.d/tool.fish and then complete -C 'tool ' outputs the completions as expected. When I try to run it in a test with fish -c 'source path/to/tool/share/fish/vendor_completions.d/tool.fish; complete -C 'tool ', I get nothing.
The tool uses @pnpm/tabtab to generate completions that uses this template: https://github.com/pnpm/tabtab/blob/main/lib/templates/completion.fish. Notice how it uses commandline -C to get cursor position.

When I try to test it from command line with fish_trace, I get this output from the beginning of that function:

> complete -C 'tool '
-> _tool_completion
----> commandline -o
---> set cmd tool
----> commandline -C
---> set cursor
----> count tool
---> set words 1

When I try it interactively, I get this:

> complete -C 'tool '
-> _tool_completion
----> commandline -o
---> set cmd tool
----> commandline -C
---> set cursor 0
----> count tool
---> set words 1

And this makes all the difference for the tool's completion machinery. Is it possible to make commandline -C return something when running in such manner? Should I run it differently to test completion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that's not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions