Skip to content

Commit

Permalink
fix(ri): properly split methods
Browse files Browse the repository at this point in the history
The current implementation of `_comp_cmd_ri__methods` generates
methods separated by newlines as a single element of COMPREPLY, which
is suspicous.  This code existed since the first implementation of the
"ri" completion in commit 309cf93.  In this patch, we try to split
the result with newlines.
  • Loading branch information
akinomyoga committed Jan 14, 2024
1 parent b63d25a commit 910a5a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions completions/ri
Expand Up @@ -14,19 +14,19 @@ _comp_cmd_ri__methods()
regex=Class
fi

COMPREPLY+=(
_comp_split -la COMPREPLY \
"$(ri ${classes[@]+"${classes[@]}"} 2>/dev/null | ruby -ane \
'if /^'"$regex"' methods:/.../^------------------|^$/ and \
/^ / then print $_.split(/, |,$/).grep(/^[^\[]*$/).join("\n"); \
end' 2>/dev/null | sort -u)")
end' 2>/dev/null | sort -u)"
else
# older versions of ri didn't distinguish between class/module and
# instance methods
COMPREPLY+=(
_comp_split -la COMPREPLY \
"$(ruby -W0 "$ri_path" ${classes[@]+"${classes[@]}"} 2>/dev/null | ruby -ane \
'if /^-/.../^-/ and ! /^-/ and ! /^ +(class|module): / then \
print $_.split(/, |,$| +/).grep(/^[^\[]*$/).join("\n"); \
end' | sort -u)")
end' | sort -u)"
fi
((${#COMPREPLY[@]})) &&
_comp_compgen -c "$method" -- "$prefix" -W '"${COMPREPLY[@]}"'
Expand Down

0 comments on commit 910a5a0

Please sign in to comment.