Skip to content

Commit b40f486

Browse files
committed
feat(shell): Parameterize binary names in inline shell completion
- Add {{CLI_BINARY_NAME}} and {{CLI_BINARY_NAME_UPPER}} placeholders to all inline shell completion .zsh files - Update build.rs to perform runtime substitution of placeholders - Replace all _q_ function prefixes with _{{CLI_BINARY_NAME}}_ - Replace all _Q_ and Q_ variable prefixes with _{{CLI_BINARY_NAME_UPPER}}_ and {{CLI_BINARY_NAME_UPPER}}_ - Replace hardcoded 'q' binary commands with {{CLI_BINARY_NAME}} - Add CLI_BINARY_NAME constant at top of build.rs This enables changing binary names by updating constants in one place.
1 parent c1f9063 commit b40f486

File tree

14 files changed

+165
-155
lines changed

14 files changed

+165
-155
lines changed

crates/fig_integrations/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const CODEX_FOLDER: &str = "src/shell/inline_shell_completion";
22

3+
// Binary name constants for parameterization
4+
const CLI_BINARY_NAME: &str = "q";
5+
36
// The order here is very specific, do no edit without understanding the implications
47
const CODEX_FILES: &[&str] = &[
58
"guard_start.zsh",
@@ -31,5 +34,12 @@ fn main() {
3134
println!("cargo:rerun-if-changed={}", path.display());
3235
inline_shell_completion.push_str(&std::fs::read_to_string(path).unwrap());
3336
}
37+
38+
// Substitute placeholders with actual binary names
39+
let cli_binary_name_upper = CLI_BINARY_NAME.to_uppercase();
40+
inline_shell_completion = inline_shell_completion
41+
.replace("{{CLI_BINARY_NAME}}", CLI_BINARY_NAME)
42+
.replace("{{CLI_BINARY_NAME_UPPER}}", &cli_binary_name_upper);
43+
3444
std::fs::write(out_dir.join("inline_shell_completion.zsh"), inline_shell_completion).unwrap();
3545
}

crates/fig_integrations/src/shell/inline_shell_completion/async.zsh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,42 @@
33
# Async #
44
#--------------------------------------------------------------------#
55

6-
_q_autosuggest_async_request() {
6+
_{{CLI_BINARY_NAME}}_autosuggest_async_request() {
77
zmodload zsh/system 2>/dev/null # For `$sysparams`
88

9-
typeset -g _Q_AUTOSUGGEST_ASYNC_FD _Q_AUTOSUGGEST_CHILD_PID
9+
typeset -g _{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ASYNC_FD _{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_CHILD_PID
1010

1111
# If we've got a pending request, cancel it
12-
if [[ -n "$_Q_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_Q_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
12+
if [[ -n "$_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
1313
# Close the file descriptor and remove the handler
14-
exec {_Q_AUTOSUGGEST_ASYNC_FD}<&-
15-
zle -F $_Q_AUTOSUGGEST_ASYNC_FD
14+
exec {_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ASYNC_FD}<&-
15+
zle -F $_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ASYNC_FD
1616

1717
# We won't know the pid unless the user has zsh/system module installed
18-
if [[ -n "$_Q_AUTOSUGGEST_CHILD_PID" ]]; then
18+
if [[ -n "$_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_CHILD_PID" ]]; then
1919
# Zsh will make a new process group for the child process only if job
2020
# control is enabled (MONITOR option)
2121
if [[ -o MONITOR ]]; then
2222
# Send the signal to the process group to kill any processes that may
2323
# have been forked by the suggestion strategy
24-
kill -TERM -$_Q_AUTOSUGGEST_CHILD_PID 2>/dev/null
24+
kill -TERM -$_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_CHILD_PID 2>/dev/null
2525
else
2626
# Kill just the child process since it wasn't placed in a new process
2727
# group. If the suggestion strategy forked any child processes they may
2828
# be orphaned and left behind.
29-
kill -TERM $_Q_AUTOSUGGEST_CHILD_PID 2>/dev/null
29+
kill -TERM $_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_CHILD_PID 2>/dev/null
3030
fi
3131
fi
3232
fi
3333

3434
# Fork a process to fetch a suggestion and open a pipe to read from it
35-
exec {_Q_AUTOSUGGEST_ASYNC_FD}< <(
35+
exec {_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ASYNC_FD}< <(
3636
# Tell parent process our pid
3737
echo $sysparams[pid]
3838
3939
# Fetch and print the suggestion
4040
local suggestion
41-
_q_autosuggest_fetch_suggestion "$1"
41+
_{{CLI_BINARY_NAME}}_autosuggest_fetch_suggestion "$1"
4242
echo -nE "$suggestion"
4343
)
4444

@@ -48,16 +48,16 @@ _q_autosuggest_async_request() {
4848
is-at-least 5.8 || command true
4949

5050
# Read the pid from the child process
51-
read _Q_AUTOSUGGEST_CHILD_PID <&$_Q_AUTOSUGGEST_ASYNC_FD
51+
read _{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_CHILD_PID <&$_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ASYNC_FD
5252

5353
# When the fd is readable, call the response handler
54-
zle -F "$_Q_AUTOSUGGEST_ASYNC_FD" _q_autosuggest_async_response
54+
zle -F "$_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ASYNC_FD" _{{CLI_BINARY_NAME}}_autosuggest_async_response
5555
}
5656

5757
# Called when new data is ready to be read from the pipe
5858
# First arg will be fd ready for reading
5959
# Second arg will be passed in case of error
60-
_q_autosuggest_async_response() {
60+
_{{CLI_BINARY_NAME}}_autosuggest_async_response() {
6161
emulate -L zsh
6262

6363
local suggestion

crates/fig_integrations/src/shell/inline_shell_completion/bind.zsh

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,44 @@
33
# Widget Helpers #
44
#--------------------------------------------------------------------#
55

6-
_q_autosuggest_incr_bind_count() {
7-
typeset -gi bind_count=$((_Q_AUTOSUGGEST_BIND_COUNTS[$1]+1))
8-
_Q_AUTOSUGGEST_BIND_COUNTS[$1]=$bind_count
6+
_{{CLI_BINARY_NAME}}_autosuggest_incr_bind_count() {
7+
typeset -gi bind_count=$((_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_BIND_COUNTS[$1]+1))
8+
_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_BIND_COUNTS[$1]=$bind_count
99
}
1010

1111
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
12-
_q_autosuggest_bind_widget() {
13-
typeset -gA _Q_AUTOSUGGEST_BIND_COUNTS
12+
_{{CLI_BINARY_NAME}}_autosuggest_bind_widget() {
13+
typeset -gA _{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_BIND_COUNTS
1414

1515
local widget=$1
1616
local autosuggest_action=$2
17-
local prefix=$Q_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX
17+
local prefix=${{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX
1818

1919
local -i bind_count
2020

2121
# Save a reference to the original widget
2222
case $widgets[$widget] in
2323
# Already bound
24-
user:_q_autosuggest_(bound|orig)_*)
25-
bind_count=$((_Q_AUTOSUGGEST_BIND_COUNTS[$widget]))
24+
user:_{{CLI_BINARY_NAME}}_autosuggest_(bound|orig)_*)
25+
bind_count=$((_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_BIND_COUNTS[$widget]))
2626
;;
2727

2828
# User-defined widget
2929
user:*)
30-
_q_autosuggest_incr_bind_count $widget
30+
_{{CLI_BINARY_NAME}}_autosuggest_incr_bind_count $widget
3131
zle -N $prefix$bind_count-$widget ${widgets[$widget]#*:}
3232
;;
3333

3434
# Built-in widget
3535
builtin)
36-
_q_autosuggest_incr_bind_count $widget
37-
eval "_q_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }"
38-
zle -N $prefix$bind_count-$widget _q_autosuggest_orig_$widget
36+
_{{CLI_BINARY_NAME}}_autosuggest_incr_bind_count $widget
37+
eval "_{{CLI_BINARY_NAME}}_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }"
38+
zle -N $prefix$bind_count-$widget _{{CLI_BINARY_NAME}}_autosuggest_orig_$widget
3939
;;
4040

4141
# Completion widget
4242
completion:*)
43-
_q_autosuggest_incr_bind_count $widget
43+
_{{CLI_BINARY_NAME}}_autosuggest_incr_bind_count $widget
4444
eval "zle -C $prefix$bind_count-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}"
4545
;;
4646
esac
@@ -51,16 +51,16 @@ _q_autosuggest_bind_widget() {
5151
# correctly. $WIDGET cannot be trusted because other plugins call
5252
# zle without the `-w` flag (e.g. `zle self-insert` instead of
5353
# `zle self-insert -w`).
54-
eval "_q_autosuggest_bound_${bind_count}_${(q)widget}() {
55-
_q_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
54+
eval "_{{CLI_BINARY_NAME}}_autosuggest_bound_${bind_count}_${(q)widget}() {
55+
_{{CLI_BINARY_NAME}}_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
5656
}"
5757

5858
# Create the bound widget
59-
zle -N -- $widget _q_autosuggest_bound_${bind_count}_$widget
59+
zle -N -- $widget _{{CLI_BINARY_NAME}}_autosuggest_bound_${bind_count}_$widget
6060
}
6161

6262
# Map all configured widgets to the right autosuggest widgets
63-
_q_autosuggest_bind_widgets() {
63+
_{{CLI_BINARY_NAME}}_autosuggest_bind_widgets() {
6464
emulate -L zsh
6565

6666
local widget
@@ -69,30 +69,30 @@ _q_autosuggest_bind_widgets() {
6969
ignore_widgets=(
7070
.\*
7171
_\*
72-
${_Q_AUTOSUGGEST_BUILTIN_ACTIONS/#/autosuggest-}
73-
$Q_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\*
74-
$Q_AUTOSUGGEST_IGNORE_WIDGETS
72+
${_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_BUILTIN_ACTIONS/#/autosuggest-}
73+
${{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\*
74+
${{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_IGNORE_WIDGETS
7575
)
7676

7777
# Find every widget we might want to bind and bind it appropriately
7878
for widget in ${${(f)"$(builtin zle -la)"}:#${(j:|:)~ignore_widgets}}; do
79-
if [[ -n ${Q_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]]; then
80-
_q_autosuggest_bind_widget $widget clear
81-
elif [[ -n ${Q_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]]; then
82-
_q_autosuggest_bind_widget $widget accept
83-
elif [[ -n ${Q_AUTOSUGGEST_EXECUTE_WIDGETS[(r)$widget]} ]]; then
84-
_q_autosuggest_bind_widget $widget execute
85-
elif [[ -n ${Q_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS[(r)$widget]} ]]; then
86-
_q_autosuggest_bind_widget $widget partial_accept
79+
if [[ -n ${{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]]; then
80+
_{{CLI_BINARY_NAME}}_autosuggest_bind_widget $widget clear
81+
elif [[ -n ${{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]]; then
82+
_{{CLI_BINARY_NAME}}_autosuggest_bind_widget $widget accept
83+
elif [[ -n ${{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_EXECUTE_WIDGETS[(r)$widget]} ]]; then
84+
_{{CLI_BINARY_NAME}}_autosuggest_bind_widget $widget execute
85+
elif [[ -n ${{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS[(r)$widget]} ]]; then
86+
_{{CLI_BINARY_NAME}}_autosuggest_bind_widget $widget partial_accept
8787
else
8888
# Assume any unspecified widget might modify the buffer
89-
_q_autosuggest_bind_widget $widget modify
89+
_{{CLI_BINARY_NAME}}_autosuggest_bind_widget $widget modify
9090
fi
9191
done
9292
}
9393

9494
# Given the name of an original widget and args, invoke it, if it exists
95-
_q_autosuggest_invoke_original_widget() {
95+
_{{CLI_BINARY_NAME}}_autosuggest_invoke_original_widget() {
9696
# Do nothing unless called with at least one arg
9797
(( $# )) || return 0
9898

crates/fig_integrations/src/shell/inline_shell_completion/config.zsh

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66
# Color to use when highlighting suggestion
77
# Uses format of `region_highlight`
88
# More info: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets
9-
(( ! ${+Q_AUTOSUGGEST_HIGHLIGHT_STYLE} )) &&
10-
typeset -g Q_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
9+
(( ! ${+{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_HIGHLIGHT_STYLE} )) &&
10+
typeset -g {{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
1111

1212
# Prefix to use when saving original versions of bound widgets
13-
(( ! ${+Q_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX} )) &&
14-
typeset -g Q_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
13+
(( ! ${+{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX} )) &&
14+
typeset -g {{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
1515

1616
# Strategies to use to fetch a suggestion
1717
# Will try each strategy in order until a suggestion is returned
18-
(( ! ${+Q_AUTOSUGGEST_STRATEGY} )) && {
19-
typeset -ga Q_AUTOSUGGEST_STRATEGY
20-
Q_AUTOSUGGEST_STRATEGY=(inline_shell_completion)
18+
(( ! ${+{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_STRATEGY} )) && {
19+
typeset -ga {{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_STRATEGY
20+
{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_STRATEGY=(inline_shell_completion)
2121
}
2222

2323
# Widgets that clear the suggestion
24-
(( ! ${+Q_AUTOSUGGEST_CLEAR_WIDGETS} )) && {
25-
typeset -ga Q_AUTOSUGGEST_CLEAR_WIDGETS
26-
Q_AUTOSUGGEST_CLEAR_WIDGETS=(
24+
(( ! ${+{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_CLEAR_WIDGETS} )) && {
25+
typeset -ga {{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_CLEAR_WIDGETS
26+
{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_CLEAR_WIDGETS=(
2727
history-search-forward
2828
history-search-backward
2929
history-beginning-search-forward
@@ -40,9 +40,9 @@ typeset -g Q_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
4040
}
4141

4242
# Widgets that accept the entire suggestion
43-
(( ! ${+Q_AUTOSUGGEST_ACCEPT_WIDGETS} )) && {
44-
typeset -ga Q_AUTOSUGGEST_ACCEPT_WIDGETS
45-
Q_AUTOSUGGEST_ACCEPT_WIDGETS=(
43+
(( ! ${+{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ACCEPT_WIDGETS} )) && {
44+
typeset -ga {{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ACCEPT_WIDGETS
45+
{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_ACCEPT_WIDGETS=(
4646
forward-char
4747
end-of-line
4848
vi-forward-char
@@ -52,16 +52,16 @@ typeset -g Q_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
5252
}
5353

5454
# Widgets that accept the entire suggestion and execute it
55-
(( ! ${+Q_AUTOSUGGEST_EXECUTE_WIDGETS} )) && {
56-
typeset -ga Q_AUTOSUGGEST_EXECUTE_WIDGETS
57-
Q_AUTOSUGGEST_EXECUTE_WIDGETS=(
55+
(( ! ${+{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_EXECUTE_WIDGETS} )) && {
56+
typeset -ga {{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_EXECUTE_WIDGETS
57+
{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_EXECUTE_WIDGETS=(
5858
)
5959
}
6060

6161
# Widgets that accept the suggestion as far as the cursor moves
62-
(( ! ${+Q_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS} )) && {
63-
typeset -ga Q_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS
64-
Q_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
62+
(( ! ${+{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS} )) && {
63+
typeset -ga {{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS
64+
{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
6565
forward-word
6666
emacs-forward-word
6767
vi-forward-word
@@ -74,9 +74,9 @@ typeset -g Q_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
7474
}
7575

7676
# Widgets that should be ignored (globbing supported but must be escaped)
77-
(( ! ${+Q_AUTOSUGGEST_IGNORE_WIDGETS} )) && {
78-
typeset -ga Q_AUTOSUGGEST_IGNORE_WIDGETS
79-
Q_AUTOSUGGEST_IGNORE_WIDGETS=(
77+
(( ! ${+{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_IGNORE_WIDGETS} )) && {
78+
typeset -ga {{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_IGNORE_WIDGETS
79+
{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_IGNORE_WIDGETS=(
8080
orig-\*
8181
beep
8282
run-help
@@ -89,5 +89,5 @@ typeset -g Q_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
8989
}
9090

9191
# Pty name for capturing completions for completion suggestion strategy
92-
(( ! ${+Q_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
93-
typeset -g Q_AUTOSUGGEST_COMPLETIONS_PTY_NAME=q_autosuggest_completion_pty
92+
(( ! ${+{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_COMPLETIONS_PTY_NAME} )) &&
93+
typeset -g {{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_COMPLETIONS_PTY_NAME=q_autosuggest_completion_pty

crates/fig_integrations/src/shell/inline_shell_completion/fetch.zsh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
# from the first strategy to provide one.
77
#
88

9-
_q_autosuggest_fetch_suggestion() {
9+
_{{CLI_BINARY_NAME}}_autosuggest_fetch_suggestion() {
1010
typeset -g suggestion
1111
local -a strategies
1212
local strategy
1313

1414
# Ensure we are working with an array
15-
strategies=(${=Q_AUTOSUGGEST_STRATEGY})
15+
strategies=(${={{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_STRATEGY})
1616

1717
for strategy in $strategies; do
1818
# Try to get a suggestion from this strategy
19-
_q_autosuggest_strategy_$strategy "$1"
19+
_{{CLI_BINARY_NAME}}_autosuggest_strategy_$strategy "$1"
2020

2121
# Ensure the suggestion matches the prefix
2222
[[ "$suggestion" != "$1"* ]] && unset suggestion
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
if command -v _zsh_autosuggest_accept >/dev/null 2>&1; then
2-
export Q_USING_ZSH_AUTOSUGGESTIONS=1
2+
export {{CLI_BINARY_NAME_UPPER}}_USING_ZSH_AUTOSUGGESTIONS=1
33
else

crates/fig_integrations/src/shell/inline_shell_completion/highlight.zsh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
#--------------------------------------------------------------------#
55

66
# If there was a highlight, remove it
7-
_q_autosuggest_highlight_reset() {
8-
typeset -g _Q_AUTOSUGGEST_LAST_HIGHLIGHT
7+
_{{CLI_BINARY_NAME}}_autosuggest_highlight_reset() {
8+
typeset -g _{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_LAST_HIGHLIGHT
99

10-
if [[ -n "$_Q_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then
11-
region_highlight=("${(@)region_highlight:#$_Q_AUTOSUGGEST_LAST_HIGHLIGHT}")
12-
unset _Q_AUTOSUGGEST_LAST_HIGHLIGHT
10+
if [[ -n "$_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then
11+
region_highlight=("${(@)region_highlight:#$_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_LAST_HIGHLIGHT}")
12+
unset _{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_LAST_HIGHLIGHT
1313
fi
1414
}
1515

1616
# If there's a suggestion, highlight it
17-
_q_autosuggest_highlight_apply() {
18-
typeset -g _Q_AUTOSUGGEST_LAST_HIGHLIGHT
17+
_{{CLI_BINARY_NAME}}_autosuggest_highlight_apply() {
18+
typeset -g _{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_LAST_HIGHLIGHT
1919

2020
if (( $#POSTDISPLAY )); then
21-
typeset -g _Q_AUTOSUGGEST_LAST_HIGHLIGHT="$#BUFFER $(($#BUFFER + $#POSTDISPLAY)) $Q_AUTOSUGGEST_HIGHLIGHT_STYLE"
22-
region_highlight+=("$_Q_AUTOSUGGEST_LAST_HIGHLIGHT")
21+
typeset -g _{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_LAST_HIGHLIGHT="$#BUFFER $(($#BUFFER + $#POSTDISPLAY)) ${{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_HIGHLIGHT_STYLE"
22+
region_highlight+=("$_{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_LAST_HIGHLIGHT")
2323
else
24-
unset _Q_AUTOSUGGEST_LAST_HIGHLIGHT
24+
unset _{{CLI_BINARY_NAME_UPPER}}_AUTOSUGGEST_LAST_HIGHLIGHT
2525
fi
2626
}

0 commit comments

Comments
 (0)