Bug fix: when editing multi-line complex command highlighting was shifted by one character starting from second line. This behaviour was due to splitting of BUFFER using shell parser ${(z)BUFFER}, which basically changes all newlines to semicolons.

This commit is contained in:
jimmijj 2014-10-03 17:26:14 +00:00
parent 6d9a34065c
commit df99f5f61a

View File

@ -84,12 +84,19 @@ _zsh_highlight_main_highlighter()
$ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR $ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS $ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR $ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
) )
splitbuf1=(${(z)BUFFER})
splitbuf2=(${(z)BUFFER//$'\n'/ \$\'\\\\n\' }) # ugly hack, but I have no other idea
local argnum=0
for arg in ${(z)BUFFER}; do for arg in ${(z)BUFFER}; do
argnum=$((argnum+1))
if [[ $splitbuf1[$argnum] != $splitbuf2[$argnum] ]] && new_expression=true && continue
local substr_color=0 isfile=false local substr_color=0 isfile=false
local style_override="" local style_override=""
[[ $start_pos -eq 0 && $arg = 'noglob' ]] && highlight_glob=false [[ $start_pos -eq 0 && $arg = 'noglob' ]] && highlight_glob=false
((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]##[[:space:]]#}})) ((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]##[[:space:]]#}}))
((end_pos=$start_pos+${#arg})) ((end_pos=$start_pos+${#arg}))
# Parse the sudo command line # Parse the sudo command line
if $sudo; then if $sudo; then
case "$arg" in case "$arg" in