Skip to content

Commit

Permalink
Fix parsing arg for user commands
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gelio committed Nov 18, 2022
1 parent 679f348 commit 911a32d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions autoload/wilder/cmdline/main.vim
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ function! wilder#cmdline#main#do(ctx) abort
elseif a:ctx.cmd ==# 'lua'
let a:ctx.expand = 'lua'
return
else
call s:move_pos_to_last_arg(a:ctx)
return
endif
endfunction

Expand Down

0 comments on commit 911a32d

Please sign in to comment.