Skip to content

Commit

Permalink
fix(mr): exactly match command names
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Sep 25, 2023
1 parent 584e567 commit 800b103
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions completions/mr
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ _comp_cmd_mr()
commands="${commands//@(action|[\[\|\]])/$'\n'}"
# Add standard aliases.
commands="${commands} ci co ls"
_comp_split commands "$commands"
local IFS='|'
local glob_commands="@(${commands[*]})"
_comp_unlocal IFS

# Determine if user has entered an `mr` command. Used to block top-level
# (option and command) completions.
local cmd has_cmd="" i
for ((i = 1; i < ${#words[@]} - 1; i++)); do
if [[ $commands == *"${words[i]}"* ]]; then
# shellcheck disable=SC2053
if [[ ${words[i]} == $glob_commands ]]; then
cmd="${words[i]}"
has_cmd=set
break
Expand Down Expand Up @@ -85,7 +90,7 @@ _comp_cmd_mr()
# -X '--path': Remove deprecated options.
_comp_compgen -- -W '"${options[@]}"' -X '@(-[a-z]|--path)'
else
_comp_compgen -- -W "${commands}"
_comp_compgen -- -W '"${commands[@]}"'
fi
} &&
complete -F _comp_cmd_mr mr
Expand Down

0 comments on commit 800b103

Please sign in to comment.