handlr-regex: handlr 0.12.0 completion scripts is faulty

Current Behavior

The generated completer is faulty. For open and mime subcommands it only complete options and will not complete paths, and completes nothing if the current word doesn’t match the options. For launch and get it only complete extensions, not options, and continues to do so after typing 2 dashes.

The new created script also seems to hard code the path to handlr by prepending cwd to argv[0] unless argv[0] is not a path. If the completion script is generated before installation the path would be invalid and suppress the original completer. Might be better to document it in the README.

Expected Behavior

It should generate completion for both options and paths/extensions. If a dash or 2 dashes are at the front of the completing word then it should complete options, and if ./ is at the front of the current word it should complete only paths.

Distribution and Version

handlr version : 0.12.0 Distribution : Artix Linux using Arch Linux extra repository

I do not see any commit to the code after the tag release so I did not compile it myself.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17 (10 by maintainers)

Most upvoted comments

@The-Ludwig Sorry about that. I have made a new patch release.

I just realized the path completion is faulty though, basically clap-rs/clap/#5239, but I can replicate it on bash and zsh, only fish is immune. I am not sure how it reappeared when it is added to CI/CD and we are using clap 4.5.

I am guessing that ValueHint and ArgValueCompleter have separate implementations, since the former is used for “static” completions and the latter is used for “dynamic” completions. So fixing a bug in one would not necessarily fix the other.

Or maybe the dynamic completions are unstable enough there are still significant holes in test coverage.

In any case, I might have to issue a bug report.

There is also lack of ~ expansion and variable expansion, the former is probably doable, latter not sure. All of these may just be with clap_complete though since you only imported the completer. This issue can probably be closed, unless it is again some issue of the code here.

I think those might be more issues with clap_complete, especially since it appears to still be kind of a work in progress a work in progress.

I do find it weird I am the only one reporting this though, maybe not many people use it directly? I often open apps from the shell instead of the file manager so I kinda have a stake in it, only if I know how to read code quickly.

That might be possible. To my understanding, users tend to mainly use handlr-regex for scripts and keybinds and mainly only directly use it in a command line for editing or viewing mimeapps.list.

Regardless, I am glad someone noticed it and reported it so that others with your use case no longer have to deal with it.