wfxr / forgit

:zzz: A utility tool powered by fzf for using git interactively.
MIT License
4.32k stars 136 forks source link

Fish completions aren't showing the flags of the subcommands correctly #371

Open cjappl opened 3 months ago

cjappl commented 3 months ago

Environment info

Problem / Steps to reproduce

Full fish completions are relatively new, but some of them are behaving strangely.

Ideally, when you do something like

gbl --<TAB>

You get all the flags available to pass into git blame:

> git blame --help
--contents  (Instead of working tree, use the contents of the named file)  --line-porcelain                     (Show the porcelain format)  --show-email  (Show the author email instead of author name)
--date                        (Specifies the format used to output dates)  --porcelain  (Show in a format designed for machine consumption)  --show-name       (Show the filename in the original commit)
--help                                  (Display manual of a Git command)  --reverse             (Walk history forward instead of backward)  --show-number  (Show the line number in the original commit)
--incremental                             (Show the result incrementally)  --root                 (Do not treat root commits as boundaries)  --show-stats                 (Include additional statistics)

Instead you get:

> git-forgit blame --

Nothing.

It seems like we are completing the files correctly, but not wrapping the flags. Filing this for the future

cjappl commented 3 months ago

@folliehiyuki just pinging you here as you wrote the original version. I'm going to dig in more at some point, but perhaps in your expertise you see the problem right away :)

folliehiyuki commented 3 months ago

Completion in fish shell is explicit. Since no completion for blame subcommand is defined in the current completion file, it behaves correctly in this case (providing nothing).

It seems like we're trying to pass completion items of git blame to git-forgit blame, which is kind of tricky. fish's complete function has -w|--wraps flag to deal with alias completion, but it doesn't work with other complete's flags apparently.

What I've tried:

# This copies all the completion arguments of `git blame` to `git-forgit`, ignoring the
# blame subcommand requirement
complete -c git-forgit -n '__fish_seen_subcommand_from blame' -w 'git blame'

# This pass all the completion items of `git` to `git-forgit`, with redundant completion
# items, which is not what we desire
complete -c git-forgit -w git

Can you try filling an issue upstream? Maybe they will add support for our use case. Also, it might already be possible but my fish-fu is not good enough to let me figure it out.

cjappl commented 3 months ago

Good investigation. I'll see if I can dive in at some point and figure out if there is a workaround or we need to file a ticket. Thanks for spending some time!!

cjappl commented 3 months ago

This has been merged, our monthly release goes out in a few days. I'll check it then (because we have a big refactor going through with that release I don't want to push it early)