-
Notifications
You must be signed in to change notification settings - Fork 34
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
Candidates for second and subsequent user command arguments are not shown #159
Comments
Thanks for the detailed info and the screenshots! I've narrowed this down to |
I'm dubious whether this is the problem with the I'm curious, what am I missing? |
wilder.nvim/autoload/wilder/cmdline.vim Lines 681 to 682 in 777b163
It doesn't handle Lua functions sincce The The fallback will be to call |
Interesting, thanks for sharing these details. Why did it work for the first argument, though? I get correct completions for the first argument of You're saying that getting the completions for the first argument works fine when using a Lua function for I'm asking out of my curiosity, so I can better understand the Vim <-> Lua user command completions interop |
Hmm, looks like I'm wrong - You can confirm this by setting |
Yup, I confirm I can see the correct completion candidates in the function FuzzyFilter(ctx, xs, c)
echomsg "ctx" a:ctx
echomsg "xs" a:xs
return a:xs
endfunction \ 'fuzzy_filter': function("FuzzyFilter"), Yields
The candidates are there. At first glance, it seems to me the |
@gelguy Is there any way I can help out more here? Should I try to adjust the |
Thanks for offering! If you're ok with waiting, I'll have a fix done over the weekend. |
That sounds great! Take your time, there's no rush, and it's just an inconvenience, not a showstopper. |
I'm sorry to bring it up, but this bug keeps annoying me. Could I help fix it? |
For user commands, the parsed `arg` was everything in the cmdline after the command name. This meant that for `:DiffviewOpen origin/master --i`, the `arg` was `origin/master --i`. The completions returned by `getcompletion(cmdline, 'cmdline')` returned the completions that are prefixed by the last argument (`--i`, for example `--imply-local`). Then, the filtering code attempted to filter the completions (`["--imply-local"]`) using `origin/master --i`, which did not match. For the `arg`, only the last argument (`--i`) should be used in this case for the filtering to return the correct completions. The consequence was that completions for the 2nd and subsequent were not shown for user commands with `complete` functions in Lua. This commit changes the cmdline parsing logic so that for user commands, only the last argument in the cmdline is parsed as the `arg`. This way the filtering logic correctly matches `--imply-local` as a valid completion for `--i`. The following commands now show completions, whereas they did not show any completions before: * :DiffviewOpen origin/master --i * :Telescope live_grep pre Fixes gelguy#159
I found a possible fix and raised #166 |
Hey 👋
I have been using this plugin for quite some time and found out there may be something wrong with the way the plugin handles candidates for user command arguments.
When trying to get completions at the end of the following command from https://github.com/sindrets/diffview.nvim:
wilder.nvim does not show any candidates for the second argument (
--imp
).It does show the candidates when I am typing the first argument (i.e. does suggest
sway
when the cmdline is:DiffviewOpen sw
).Investigation notes
Here are some debug logs from my investigation from some of the values used in wilder.nvim for the
ctx
and thearg
:The suggestions returned from the
DiffviewOpen
user command at that point are:{ "--imply-local" }
It looks like wilder.nvim assumes that the argument is
sway --imp
and not just--imp
. Thus, later, when it tries to match the completion candidates (--imply-local
) against thearg
, it does not find the match, becausesway --imp
does not match--imply-local
. If it only used the last argument (--imp
), it would correctly find the match between--imp
and--imply-local
.I suspect the problem is somewhere in
wilder.nvim/autoload/wilder/cmdline/main.vim
Line 36 in 679f348
The function is quite complex and I didn't end up finding the problem, unfortunately.
Native wildmenu behavior
To check whether this is a wrong assumption of wilder.nvim or a problem in diffview.nvim completion candidates, I checked how the native wildmenu behaves. It correctly offers completions for the second argument:
After pressing
Tab
for:DiffviewOpen sway --imp
, the argument is correctly completed to:DiffviewOpen sway --imply-local
. Completing subsequent arguments works in the native wildmenu as well:Other problematic plugins
The problem can be reproduced with other plugins that have completions for more than one user command argument. For example, with
:Telescope live_grep |
(|
is the cursor position), there are no completions shown by wilder.nvim, but there are many completions shown in the native wildmenu.The text was updated successfully, but these errors were encountered: