mirror of
https://github.com/zsh-users/zsh-syntax-highlighting
synced 2025-01-05 10:19:30 +00:00
sudo: Tweak state computations.
This causes the ':start:' state to be set in $next_word in iteration N-1, rather than to only be added to $this_word in iteration N.
This commit is contained in:
parent
f49f3bf0c0
commit
9cb87473cc
@ -192,11 +192,14 @@ _zsh_highlight_main_highlighter()
|
||||
'-'[Cgprtu]) this_word=${this_word//:start:/};
|
||||
next_word=':sudo_arg:';;
|
||||
# This prevents misbehavior with sudo -u -otherargument
|
||||
'-'*) next_word+=':sudo_opt:';;
|
||||
*) this_word+=':start:';;
|
||||
'-'*) this_word=${this_word//:start:/};
|
||||
next_word+=':start:';
|
||||
next_word+=':sudo_opt:';;
|
||||
*) ;;
|
||||
esac
|
||||
elif [[ $this_word == *':sudo_arg:'* ]]; then
|
||||
next_word+=':sudo_opt:'
|
||||
next_word+=':start:'
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -205,8 +208,9 @@ _zsh_highlight_main_highlighter()
|
||||
style=$ZSH_HIGHLIGHT_STYLES[precommand]
|
||||
elif [[ "$arg" = "sudo" ]]; then
|
||||
style=$ZSH_HIGHLIGHT_STYLES[precommand]
|
||||
next_word+=':sudo_opt:'
|
||||
next_word=${next_word//:regular:/}
|
||||
next_word+=':sudo_opt:'
|
||||
next_word+=':start:'
|
||||
else
|
||||
_zsh_highlight_main_highlighter_expand_path $arg
|
||||
local expanded_arg="$REPLY"
|
||||
|
Loading…
Reference in New Issue
Block a user