fix(shell): add space if needed when using smart autocomplete (#200)

This commit is contained in:
Alex Pasmantier 2024-12-31 18:21:07 +01:00 committed by GitHub
parent 690e88dd1a
commit a74deceb98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,9 @@ function tv_smart_autocomplete() {
local output=$(tv --autocomplete-prompt "$current_prompt")
if [[ -n $output ]]; then
# add a space if the prompt does not end with one
[[ "${current_prompt}" != *" " ]] && current_prompt="${current_prompt} "
READLINE_LINE=$current_prompt$output
READLINE_POINT=${#READLINE_LINE}
fi

View File

@ -4,6 +4,8 @@ function tv_smart_autocomplete
set -l output (tv --autocomplete-prompt "$current_prompt")
if test -n "$output"
# add a space if the prompt does not end with one
string match -q "* " -- "$current_prompt" || set current_prompt "$current_prompt "
commandline -r "$current_prompt$output"
end
end

View File

@ -13,6 +13,8 @@ _tv_smart_autocomplete() {
if [[ -n $output ]]; then
zle reset-prompt
RBUFFER=""
# add a space if the prompt does not end with one
[[ "${current_prompt}" != *" " ]] && current_prompt="${current_prompt} "
LBUFFER=$current_prompt$output
# uncomment this to automatically accept the line