mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2026-05-01 00:40:38 +02:00
fix bugs in _p10k completion
- Fix segments+=("$segments") -> segments+=("$reselem")
- Add local declarations for loop variables to prevent scope leaks
- Fix hadkkSecond typo -> hadSecond
- Fix hardcoded '=' -> use $equals variable
- Fix missing '[' in -s segment flag description
- Add missing 'finalize' subcommand
- Add local for arguments in __p10k_segment
This commit is contained in:
parent
da29e0013d
commit
f2bd8daf90
1 changed files with 20 additions and 20 deletions
20
_p10k
20
_p10k
|
|
@ -4,6 +4,7 @@ __p10k_getpart(){
|
||||||
|
|
||||||
local -aU keys lines sides segments __p10k_prompt_selectors
|
local -aU keys lines sides segments __p10k_prompt_selectors
|
||||||
local -A reply
|
local -A reply
|
||||||
|
local equals resparts resline resside reselem resCnt hadSecond hadThird
|
||||||
lines=()
|
lines=()
|
||||||
sides=()
|
sides=()
|
||||||
segments=()
|
segments=()
|
||||||
|
|
@ -29,7 +30,7 @@ __p10k_getpart(){
|
||||||
__p10k_prompt_selectors+=("$resline/$resside$equals")
|
__p10k_prompt_selectors+=("$resline/$resside$equals")
|
||||||
sides+=("$resside")
|
sides+=("$resside")
|
||||||
else
|
else
|
||||||
segments+=("$segments")
|
segments+=("$reselem")
|
||||||
__p10k_prompt_selectors+=("$resline/$resside/$reselem$equals")
|
__p10k_prompt_selectors+=("$resline/$resside/$reselem$equals")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -39,7 +40,7 @@ __p10k_getpart(){
|
||||||
p10k display -a "$line/*"
|
p10k display -a "$line/*"
|
||||||
keys=( ${(uk)reply} )
|
keys=( ${(uk)reply} )
|
||||||
|
|
||||||
hadkkSecond=false
|
hadSecond=false
|
||||||
hadThird=false
|
hadThird=false
|
||||||
for k in ${keys[@]};do
|
for k in ${keys[@]};do
|
||||||
|
|
||||||
|
|
@ -59,7 +60,7 @@ __p10k_getpart(){
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $hadSecond == true ]]; then
|
if [[ $hadSecond == true ]]; then
|
||||||
__p10k_prompt_selectors+=("$line/*=")
|
__p10k_prompt_selectors+=("$line/*$equals")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $hadThird == true ]]; then
|
if [[ $hadThird == true ]]; then
|
||||||
|
|
@ -145,14 +146,16 @@ __p10k_display(){
|
||||||
|
|
||||||
__p10k_segment(){
|
__p10k_segment(){
|
||||||
|
|
||||||
|
local arguments
|
||||||
|
|
||||||
arguments=(
|
arguments=(
|
||||||
'-t[segment main content; will undergo prompt expansion]:text'
|
'-t[segment main content; will undergo prompt expansion]:text'
|
||||||
'-i[segment icon; default is empty]:icon'
|
'-i[segment icon; default is empty]:icon'
|
||||||
'-r[icon is a symbolic reference that needs to be resolved]'
|
'-r[icon is a symbolic reference that needs to be resolved]'
|
||||||
'+r[icon is already resolved and should be printed literally; for example,⭐]'
|
'+r[icon is already resolved and should be printed literally]'
|
||||||
'-b[background color; for example, empty value means]:bg'
|
'-b[background color; for example, empty value means]:bg'
|
||||||
'-f[foreground color; for example, empty value means]:fg'
|
'-f[foreground color; for example, empty value means]:fg'
|
||||||
'-s:segment state for the purpose of applying styling options]:state'
|
'-s[segment state for the purpose of applying styling options]:state'
|
||||||
'-c[if empty after parameter expansion and process substitution]:condition'
|
'-c[if empty after parameter expansion and process substitution]:condition'
|
||||||
'-e[segment main content will undergo parameter expansion and process]'
|
'-e[segment main content will undergo parameter expansion and process]'
|
||||||
'+e[segment main content should not undergo parameter expansion and process]'
|
'+e[segment main content should not undergo parameter expansion and process]'
|
||||||
|
|
@ -170,6 +173,7 @@ function _p10k(){
|
||||||
|
|
||||||
__p10k_commands=(
|
__p10k_commands=(
|
||||||
'configure:run interactive configuration wizard'
|
'configure:run interactive configuration wizard'
|
||||||
|
'finalize:finish instant prompt initialization'
|
||||||
'reload:reload configuration'
|
'reload:reload configuration'
|
||||||
'segment:print a user-defined prompt segment'
|
'segment:print a user-defined prompt segment'
|
||||||
'display:show, hide or toggle prompt parts'
|
'display:show, hide or toggle prompt parts'
|
||||||
|
|
@ -191,11 +195,7 @@ function _p10k(){
|
||||||
verb=$words[1]
|
verb=$words[1]
|
||||||
curcontext="${curcontext%:*:*}:p10k-$verb:"
|
curcontext="${curcontext%:*:*}:p10k-$verb:"
|
||||||
case $verb in
|
case $verb in
|
||||||
configure)
|
configure|reload|finalize)
|
||||||
_message 'no more arguments'
|
|
||||||
ret=1
|
|
||||||
;;
|
|
||||||
reload)
|
|
||||||
_message 'no more arguments'
|
_message 'no more arguments'
|
||||||
ret=1
|
ret=1
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue